3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $foo; public function __construct($foo) { $this->foo = $foo; } private function bar() { echo 'Accessed the private method.'; } public function baz(Test $other) { // We can change the private property: $other->foo = 'hello'; echo $other->foo; // We can also call the private method: $other->bar(); } private getFoo(){ return $this->foo; } } $test = new Test('test'); $test->baz(new Test('other')); echo $test->getFoo(); ?>
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'getFoo' (T_STRING), expecting variable (T_VARIABLE) in /in/AuNHA on line 26
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/AuNHA on line 26
Process exited with code 255.

preferences:
185.52 ms | 1395 KiB | 64 Q