<?php
class Test
{
private $private = "";
public function add($string) {
$this->private[] = $string;
}
public function evaluate(Test $container) {
return $container->private;
}
}
$test = new Test();
$test->add("zero");
$test->add("one");
$test->add("two");
$result = new Test();
print_r($test->private);
Fatal error: Uncaught Error: [] operator not supported for strings in /in/F5n8h:8
Stack trace:
#0 /in/F5n8h(17): Test->add('zero')
#1 {main}
thrown in /in/F5n8h on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Fatal error: Uncaught Error: Cannot access private property Test::$private in /in/F5n8h:22
Stack trace:
#0 {main}
thrown in /in/F5n8h on line 22
Process exited with code 255.
Fatal error: Cannot access private property Test::$private in /in/F5n8h on line 22
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/F5n8h on line 5
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/F5n8h on line 5
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/F5n8h on line 5
Process exited with code 255.