note 101526 added to function.property-exists
| From: | foddex at foddex dot net | Date: | Wed, 22 Dec 2010 09:56:35 +0000 |
| Subject: | note 101526 added to function.property-exists | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-175139@lists.php.net to get a copy of this message | ||
Note that before PHP 5.3.3, this function fails for private properties in base classes (which is
fixed in 5.3.3)
<?php
class Base {
private $var = 1;
public function test() {
var_dump( property_exists( $this, 'var' ) );
}
}
class Derived extends Base {
}
$b = new Base();
$b->test();
$d = new Derived();
$d->test();
?>
Executing this code with PHP 5.0 <= x < 5.3 this script echoes (incorrect result):
bool(true)
bool(false)
Executing this code with PHP 5.3 this script echoes (correct result):
bool(true)
bool(true)
----
Server IP: 213.249.64.162
Probable Submitter: 95.130.232.136
----
Manual Page -- http://www.php.net/manual/en/function.property-exists.php
Edit -- https://master.php.net/note/edit/101526
Del: integrated -- https://master.php.net/note/delete/101526/integrated
Del: useless -- https://master.php.net/note/delete/101526/useless
Del: bad code -- https://master.php.net/note/delete/101526/bad+code
Del: spam -- https://master.php.net/note/delete/101526/spam
Del: non-english -- https://master.php.net/note/delete/101526/non-english
Del: in docs -- https://master.php.net/note/delete/101526/in+docs
Del: other reasons-- https://master.php.net/note/delete/101526
Reject -- https://master.php.net/note/reject/101526
Search -- https://master.php.net/manage/user-notes.php