the question title seems pretty confusing, but this is what i want to achieve.
i have two classes
1. Category
2. Validation
In Category Class i have the following Class Property
public $error; //holds all errors in an array.
private $dbh; //Database object Handle(PDO).
private $validate; //Holds Validation Object
private $data = array('categoryName',
'subCategoryName',
'prefix',
'categoryId',
'subCategoryId');
in Validation Class i have defined a method.
public function required($fields = array()) {
foreach($fields as $field) {
if(empty(__CLASS__::data[$field])) {
}
}
}
now when i call the method $this->validate->required()
within the class Category
it should check the condition if $data[field] of Category class is empty or got any value in it. hence i have used the following syntax which does not seems to work. if(empty(__CLASS__::data[$field]))
what the condition should check is if the class property $data of the class it is being called from (it is class Category in this case) is empty or not. what is the correct syntax for fetching the class property dynamically?
thank you..