3v4l.org

run code in 300+ PHP versions simultaneously
<?php function baz($a){ unset($a); echo "2\n"; var_dump(func_get_args()); }; echo "1\n"; baz(new class(){ function __destruct(){ echo "destruct\n"; }}); echo "3\n";
Output for 7.1.10 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.24, 8.3.0 - 8.3.12
1 destruct 2 array(1) { [0]=> NULL } 3
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
1 destruct 2 array(0) { } 3
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/3l7ps on line 9
Process exited with code 255.

preferences:
80.36 ms | 408 KiB | 5 Q