note 67581 added to function.property-exists
| From: | jcaplan at bogus dot amazon dot com | Date: | Thu, 08 Jun 2006 21:35:09 +0000 |
| Subject: | note 67581 added to function.property-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-113933@lists.php.net to get a copy of this message | ||
The documentation leaves out the important case of new properties you add to objects at run time.
In fact, property_exists will return true if you ask it about such properties.
<?
class Y {}
$y = new Y;
echo isset( $y->prop ) ? "yes\n" : "no\n"; // no;
echo property_exists( 'Y', 'prop' ) ? "yes\n" : "no\n"; //
no
echo property_exists( $y, 'prop' ) ? "yes\n" : "no\n"; // no
$y->prop = null;
echo isset( $y->prop ) ? "yes\n" : "no\n"; // no;
echo property_exists( 'Y', 'prop' ) ? "yes\n" : "no\n"; //
no
echo property_exists( $y, 'prop' ) ? "yes\n" : "no\n"; // yes
?>
----
Server IP: 66.163.161.117
Probable Submitter: 207.171.180.101
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.property-exists.php
Edit -- http://master.php.net/note/edit/67581
Del: integrated -- http://master.php.net/note/delete/67581/integrated
Del: useless -- http://master.php.net/note/delete/67581/useless
Del: bad code -- http://master.php.net/note/delete/67581/bad+code
Del: spam -- http://master.php.net/note/delete/67581/spam
Del: non-english -- http://master.php.net/note/delete/67581/non-english
Del: in docs -- http://master.php.net/note/delete/67581/in+docs
Del: other reasons-- http://master.php.net/note/delete/67581
Reject -- http://master.php.net/note/reject/67581
Search -- http://master.php.net/manage/user-notes.php