3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $a = 'ahoj'; private function __invoke(&$a) { echo $this->a; } } $a = new A; /*$a('ahoj'); $ref = new \ReflectionMethod($a, '__invoke'); $ref->setAccessible(true); $ref->invoke($a, 'ahoj');*/ function f_a(&$a) { } f_a(2);
Output for 8.3.0 - 8.3.6
Warning: The magic method A::__invoke() must have public visibility in /in/Raqom on line 5 Fatal error: Uncaught Error: f_a(): Argument #1 ($a) could not be passed by reference in /in/Raqom:21 Stack trace: #0 {main} thrown in /in/Raqom on line 21
Process exited with code 255.
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18
Warning: The magic method A::__invoke() must have public visibility in /in/Raqom on line 5 Fatal error: Uncaught Error: f_a(): Argument #1 ($a) cannot be passed by reference in /in/Raqom:21 Stack trace: #0 {main} thrown in /in/Raqom on line 21
Process exited with code 255.
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.24
Fatal error: Only variables can be passed by reference in /in/Raqom on line 21
Process exited with code 255.

preferences:
92.74 ms | 402 KiB | 81 Q