note 110414 added to reflectionproperty.setaccessible
| From: | matthieu at mnapoli dot fr | Date: | Fri, 19 Oct 2012 20:50:28 +0000 |
| Subject: | note 110414 added to reflectionproperty.setaccessible | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191438@lists.php.net to get a copy of this message | ||
Note that the property will only become accessible using the ReflectionProperty class. The property
is still private or protected in the class instances.
<?php
class MyClass {
private $myProperty = true;
}
$class = new ReflectionClass("MyClass");
$property = $class->getProperty("myProperty");
$property->setAccessible(true);
$obj = new MyClass();
echo $property->getValue($obj); // Works
echo $obj->myProperty; // Doesn't work (error)
?>
----
Server IP: 195.221.21.36
Probable Submitter: 82.67.26.219
----
Manual Page -- http://www.php.net/manual/en/reflectionproperty.setaccessible.php
Edit -- https://master.php.net/note/edit/110414
Del: integrated -- https://master.php.net/note/delete/110414/integrated
Del: useless -- https://master.php.net/note/delete/110414/useless
Del: bad code -- https://master.php.net/note/delete/110414/bad+code
Del: spam -- https://master.php.net/note/delete/110414/spam
Del: non-english -- https://master.php.net/note/delete/110414/non-english
Del: in docs -- https://master.php.net/note/delete/110414/in+docs
Del: other reasons-- https://master.php.net/note/delete/110414
Reject -- https://master.php.net/note/reject/110414
Search -- https://master.php.net/manage/user-notes.php