3v4l.org

run code in 300+ 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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.13
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:
146.92 ms | 408 KiB | 5 Q