note 116824 added to function.property-exists
| From: | g dot gentile at parentesigraffe dot com | Date: | Thu, 05 Mar 2015 09:02:33 +0000 |
| Subject: | note 116824 added to function.property-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-201863@lists.php.net to get a copy of this message | ||
The function behaves differently depending on whether the property has been present in the class
declaration, or has been added dynamically, if the variable has been unset()
<?php
class TestClass {
public $declared = null;
}
$testObject = new TestClass;
var_dump(property_exists("TestClass", "dynamic")); // boolean false, as expected
var_dump(property_exists($testObject, "dynamic")); // boolean false, same as above
$testObject->dynamic = null;
var_dump(property_exists($testObject, "dynamic")); // boolean true
unset($testObject->dynamic);
var_dump(property_exists($testObject, "dynamic")); // boolean false, again.
var_dump(property_exists($testObject, "declared")); // boolean true, as espected
unset($testObject->declared);
var_dump(property_exists($testObject, "declared")); // boolean true, even if has been
unset()
----
Server IP: 72.52.91.14
Probable Submitter: 2.237.0.145
----
Manual Page -- http://php.net/manual/en/function.property-exists.php
Edit -- https://master.php.net/note/edit/116824
Del: integrated -- https://master.php.net/note/delete/116824/integrated
Del: useless -- https://master.php.net/note/delete/116824/useless
Del: bad code -- https://master.php.net/note/delete/116824/bad+code
Del: spam -- https://master.php.net/note/delete/116824/spam
Del: non-english -- https://master.php.net/note/delete/116824/non-english
Del: in docs -- https://master.php.net/note/delete/116824/in+docs
Del: other reasons-- https://master.php.net/note/delete/116824
Reject -- https://master.php.net/note/reject/116824
Search -- https://master.php.net/manage/user-notes.php