3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $instanceData = "baz"; public function bar() { var_dump($this->instanceData); } } function on(callable $c) // Warning, no call { $c(); // Warning, call } $c = ["Foo", "bar"]; // No warning, no call on($c);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught TypeError: on(): Argument #1 ($c) must be of type callable, array given, called in /in/cUFLk on line 19 and defined in /in/cUFLk:13 Stack trace: #0 /in/cUFLk(19): on(Array) #1 {main} thrown in /in/cUFLk on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.6 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Non-static method Foo::bar() should not be called statically in /in/cUFLk on line 13 Deprecated: Non-static method Foo::bar() should not be called statically in /in/cUFLk on line 15 Fatal error: Uncaught Error: Using $this when not in object context in /in/cUFLk:9 Stack trace: #0 /in/cUFLk(15): Foo::bar() #1 /in/cUFLk(19): on(Array) #2 {main} thrown in /in/cUFLk on line 9
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Using $this when not in object context in /in/cUFLk:9 Stack trace: #0 /in/cUFLk(15): Foo::bar() #1 /in/cUFLk(19): on(Array) #2 {main} thrown in /in/cUFLk on line 9
Process exited with code 255.

preferences:
169.99 ms | 402 KiB | 198 Q