note 114281 deleted from function.property-exists by cmb
| From: | cmb@php.net | Date: | Wed, 30 Nov 2016 16:37:13 +0000 |
| Subject: | note 114281 deleted from function.property-exists by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207762@lists.php.net to get a copy of this message | ||
Note Submitter: berimbolo
----
When you are testing for a property that has been added dynamically, you will need to provide a
reference to the instance rather than the class name for the first parameter.
For example, for this code snippet:
class myClass {
public $var;
}
$obj = new myClass;
$obj->new_var = "new";
var_dump(property_exists('myClass', 'new_var') );
var_dump(property_exists($obj, 'new_var') );
Returns:
boolean false
boolean true