3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function test() { echo $undef; } public function test2() { $x = $this; // use $this echo $undef; } } set_error_handler(function($_1, $_2, $_3, $_4, $ctx) { var_dump(isset($ctx['this'])); }); (new Foo)->test(); (new Foo)->test2();
Output for 8.4.1 - 8.4.12
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure:/in/sQBL9:13}(), 4 passed in /in/sQBL9 on line 5 and exactly 5 expected in /in/sQBL9:13 Stack trace: #0 /in/sQBL9(5): {closure:/in/sQBL9:13}(2, 'Undefined varia...', '/in/sQBL9', 5) #1 /in/sQBL9(16): Foo->test() #2 {main} thrown in /in/sQBL9 on line 13
Process exited with code 255.
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 4 passed in /in/sQBL9 on line 5 and exactly 5 expected in /in/sQBL9:13 Stack trace: #0 /in/sQBL9(5): {closure}(2, 'Undefined varia...', '/in/sQBL9', 5) #1 /in/sQBL9(16): Foo->test() #2 {main} thrown in /in/sQBL9 on line 13
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 4 passed and exactly 5 expected in /in/sQBL9:13 Stack trace: #0 /in/sQBL9(5): {closure}(2, 'Undefined varia...', '/in/sQBL9', 5) #1 /in/sQBL9(16): Foo->test() #2 {main} thrown in /in/sQBL9 on line 13
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
bool(false) bool(false)
Output for 5.6.0 - 5.6.28, 7.0.0 - 7.0.20
bool(false) bool(true)

preferences:
102.18 ms | 412 KiB | 5 Q