3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function var_types() { $bt = debug_backtrace()[0]; $file = new \SPLFileObject($bt['file']); $file->seek($bt['line'] - 1); $line = $file->current(); $matchs = null; preg_match('/var_types\((.*)\)/', $line, $matchs); $param_names = array_map('trim', explode(",", $matchs[1])); $args = func_get_args(); for ($i = 0; $i < count($args); $i++) { echo $param_names[$i] . ' ' . gettype($args[$i]) . PHP_EOL; } } define('MY_CONSTANT', 1); $string = "STR"; $num = 123.4; var_types(MY_CONSTANT, $string, $num, $_GET, $_SERVER['PHP_SELF']);
based on t9Aoa
Output for 5.6.0 - 5.6.30, hhvm-3.12.14 - 3.21.3, 7.0.0 - 7.3.0rc6
MY_CONSTANT integer $string string $num double $_GET array $_SERVER['PHP_SELF'] string
Output for hhvm-3.22.0
Fatal error: Uncaught exception 'LogicException' with message 'Can't seek file /in/522df to negative line -2' in /in/522df:-1 Stack trace: #0 /in/522df(-1): SplFileObject->seek() #1 /in/522df(-1): var_types() #2 {main}
Process exited with code 255.