3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tokens = token_get_all(" <?php class Foo { function __halt_compiler(){} } (new Foo())->__halt_compiler(); not_html(); ", TOKEN_PARSE ); array_walk($tokens, function($tk) { if(is_array($tk)) { if(($t = token_name($tk[0])) == 'T_WHITESPACE') return; echo "L{$tk[2]}: ".$t." {$tk[1]}", PHP_EOL; } else echo $tk, PHP_EOL; });
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Parse error: syntax error, unexpected token "__halt_compiler" in on line 5
Process exited with code 255.
Output for 7.0.6 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Parse error: syntax error, unexpected '__halt_compiler' (T_HALT_COMPILER) in on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.5
L1: T_INLINE_HTML L2: T_OPEN_TAG <?php L4: T_CLASS class L4: T_STRING Foo { L5: T_FUNCTION function L5: T_STRING __halt_compiler ( ) { } } ( L8: T_NEW new L8: T_STRING Foo ( ) ) L8: T_OBJECT_OPERATOR -> L8: T_STRING __halt_compiler ( ) ; L10: T_STRING not_html ( ) ;
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Notice: Use of undefined constant TOKEN_PARSE - assumed 'TOKEN_PARSE' in /in/GvHkY on line 15 Warning: token_get_all() expects exactly 1 parameter, 2 given in /in/GvHkY on line 15 Warning: array_walk() expects parameter 1 to be array, null given in /in/GvHkY on line 23

preferences:
67.54 ms | 2181 KiB | 4 Q