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 'Доступ к закрытому методу.'; } public function baz(Test $other) { // Мы можем изменить закрытое свойство: $other->foo = 'hello'; var_dump($other->foo); // Мы также можем вызвать закрытый метод: $other->bar(); } } $test = new Test('test'); $test->baz(new Test('other')); ?>

preferences:
56.11 ms | 402 KiB | 5 Q