3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private $c = "Secret"; } $a = function() { echo $this->c."\n"; $this->c = "new Secret"; echo $this->c; }; $b = $a->bind($a,"\\A"); $b();
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: Closure::bind(): Argument #2 ($newThis) must be of type ?object, string given in /in/V0MpW:13 Stack trace: #0 /in/V0MpW(13): Closure::bind(Object(Closure), '\\A') #1 {main} thrown in /in/V0MpW on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: Closure::bind() expects parameter 2 to be object, string given in /in/V0MpW on line 13 Fatal error: Uncaught Error: Function name must be a string in /in/V0MpW:14 Stack trace: #0 {main} thrown in /in/V0MpW on line 14
Process exited with code 255.
Output for 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Warning: Closure::bind() expects parameter 2 to be object, string given in /in/V0MpW on line 13 Fatal error: Function name must be a string in /in/V0MpW on line 14
Process exited with code 255.

preferences:
174.35 ms | 402 KiB | 226 Q