<?php
class User {
public $name = 'Adrian';
protected $ssn = 'XXX-AA-YYY';
private $salary = 5400.00;
}
$user = new User();
echo$user->name;
//echo$user->ssn;
//echo$user->salary;
$reflector = new ReflectionClass('User');
foreach($reflector->getProperties() as $prop) {
$prop->setAccessible(true);
if($prop->getName() == 'name') $prop->setValue($user, 'Alice');
if($prop->getName() == 'ssn') $prop->setValue($user, 'YYY-BB-YYY');
if($prop->getName() == 'salary') $prop->setValue($user, 7000);
}
?>
PD9waHAKICAgICBjbGFzcyBVc2VyIHsKICAgICAgICAgICBwdWJsaWMgJG5hbWUgPSAnQWRyaWFuJzsKICAgICAgICAgICBwcm90ZWN0ZWQgJHNzbiA9ICdYWFgtQUEtWVlZJzsKICAgICAgICAgICBwcml2YXRlICRzYWxhcnkgPSA1NDAwLjAwOwogICAgIH0KCiAgICAgJHVzZXIgPSBuZXcgVXNlcigpOwogICAgIGVjaG8kdXNlci0+bmFtZTsKICAgICAvL2VjaG8kdXNlci0+c3NuOyAKICAgICAvL2VjaG8kdXNlci0+c2FsYXJ5OyAKICAgICAKICAgICB2YXJfZHVtcCgkdXNlcik7CiAgICAgCgogICAgICRyZWZsZWN0b3IgPSBuZXcgUmVmbGVjdGlvbkNsYXNzKCdVc2VyJyk7IAogICAgIAogICAgIGZvcmVhY2goJHJlZmxlY3Rvci0+Z2V0UHJvcGVydGllcygpIGFzICRwcm9wKSB7CiAgICAgICAKICAgICAgICAgJHByb3AtPnNldEFjY2Vzc2libGUodHJ1ZSk7CiAgICAgICAKICAgICAgICAgaWYoJHByb3AtPmdldE5hbWUoKSA9PSAnbmFtZScpICRwcm9wLT5zZXRWYWx1ZSgkdXNlciwgJ0FsaWNlJyk7CiAgICAgICAgIGlmKCRwcm9wLT5nZXROYW1lKCkgPT0gJ3NzbicpICRwcm9wLT5zZXRWYWx1ZSgkdXNlciwgJ1lZWS1CQi1ZWVknKTsKICAgICAgICAgaWYoJHByb3AtPmdldE5hbWUoKSA9PSAnc2FsYXJ5JykgJHByb3AtPnNldFZhbHVlKCR1c2VyLCA3MDAwKTsKICAgICB9CgogICAgIAogICAgIHZhcl9kdW1wKCR1c2VyKTsKICAgICAKCj8+