note 109899 added to function.get-object-vars
| From: | Anonymous | Date: | Sat, 01 Sep 2012 15:44:34 +0000 |
| Subject: | note 109899 added to function.get-object-vars | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-190405@lists.php.net to get a copy of this message | ||
You can access private properties from PHP without the overhead of regular expressions, here is a
simple example
<?php
class a {
private $x = 500;
private $c = 600;
}
$a = new a();
$ref = new ReflectionObject($a);
$properties = $ref->getProperties();
$properties[0]->setAccessible(true);
print_r($properties[0]->getValue($a));
?>
Note: Make sure you are calling setAccessible and passing it true when trying to get private or
protected properties.
----
Server IP: 69.147.83.197
Probable Submitter: 71.48.230.111
----
Manual Page -- http://www.php.net/manual/en/function.get-object-vars.php
Edit -- https://master.php.net/note/edit/109899
Del: integrated -- https://master.php.net/note/delete/109899/integrated
Del: useless -- https://master.php.net/note/delete/109899/useless
Del: bad code -- https://master.php.net/note/delete/109899/bad+code
Del: spam -- https://master.php.net/note/delete/109899/spam
Del: non-english -- https://master.php.net/note/delete/109899/non-english
Del: in docs -- https://master.php.net/note/delete/109899/in+docs
Del: other reasons-- https://master.php.net/note/delete/109899
Reject -- https://master.php.net/note/reject/109899
Search -- https://master.php.net/manage/user-notes.php