Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class A {
- private $data;
- public function setData($value)
- {
- $this->data = $value;
- }
- }
- $a = new A;
- $a->setData('hello world');
- #echo $a->data; //error
- $reflector = new ReflectionClass('A');
- $properties = $reflector->getProperties();
- foreach ($properties as $property) {
- $property->setAccessible(true);
- echo $property->getValue($a) . PHP_EOL; // hello world
- #$property->setAccessible(false);
- #echo $property->getValue($a) . PHP_EOL; // error
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement