3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php class Test { private $foo; public function __construct($foo) { $this->foo = $foo; } private function bar() { echo 'Доступ к закрытому методу.'; } public function baz(Test $other) { // Мы можем изменить закрытое свойство: $other->foo = 'hello'; var_dump($other->foo); // Мы также можем вызвать закрытый метод: $other->bar(); } } $test = new Test('test'); $test->baz(new Test('other')); ?>
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected '<', expecting end of file in /in/9cIF6 on line 3
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected '<' in /in/9cIF6 on line 3
Process exited with code 255.

preferences:
182.98 ms | 1399 KiB | 26 Q