3v4l.org

run code in 500+ PHP versions simultaneously
<?php class A { public function test($b) { print $b->x; } } class B { private $x = 123; } $a = new A; $b = new B; $a->test($b);
Output for 7.1.25 - 7.1.27, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Cannot access private property B::$x in /in/J0lsN:7 Stack trace: #0 /in/J0lsN(19): A->test(Object(B)) #1 {main} thrown in /in/J0lsN on line 7
Process exited with code 255.

preferences:
103.39 ms | 1431 KiB | 4 Q