PHP, is_array() generating an "Undefined property: stdClass::$crit " error
- by Brook Julias
is_array($src2->crit) is generating an "Undefined property: stdClass::$crit" error.
The line throwing the error is:
if(is_array($src2->crit) && count($src->crit) > 0){
$src2->crit is initialized here.
$src2->crit = array();
$src2->crit[0] = new dataSet();
$src2->crit[0]->tblName = $tbl2;
$src2->crit[0]->colName = "ID";
$src2->crit[0]->val = $elm->editID;
When testing $src2->crit with this code.
print("\$src->crit is a ".$src->crit."<br />");
print_r($src->crit); print("<br />");
This is returned.
$src2->crit is a Array
Array ( [0] => dataSet Object ( [tblName] => sExam [colName] => ID [val] => 10 ) )
What am I not seeing/understanding correctly? If print("\$src2->crit is a ".$src->crit."<br />") returns that it is an array then why is is_array($src2->$crit) generating an error?