<?php
class foo
{
private $bar = null;
public function __set($name, $value)
{
if ($name == 'bar')
$this->bar = $value . $value;
else
throw new Exception('Property does not exists');
}
public function __get($name)
{
if ($name == 'bar')
return $this->bar;
else
throw new Exception('Property does not exists');
}
}
$obj = new foo();
$obj->bar = '123';
echo $obj->bar;
Fatal error: Cannot access private property foo::$bar in /in/0POt4 on line 27
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/0POt4 on line 6
Process exited with code 255.
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/0POt4 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/0POt4 on line 6
Process exited with code 255.