funktioniert:
Wirft einen Fatal Error:
PHP-Code:
class foo {
private $data = array();
private $something = 123;
public function __get($name) {
return $data[$name];
}
public function __set($name, $value) {
$this->data[$name] = $value;
}
}
$obj = new foo();
$obj->somebody = 'Hello';
$obj->something = 'World';
PHP-Code:
class bar {
private $something = 123;
}
$obj = new bar();
$obj->somebody = 'Hello';
$obj->something = 'World';
// Fatal error: Cannot access private property bar::$something in ... on line ...
Kommentar