3v4l.org

run code in 300+ PHP versions simultaneously
<?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']);
Output for 7.0.0 - 7.0.27, 7.1.0 - 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.31, 8.2.0 - 8.2.28, 8.3.0 - 8.3.19, 8.4.1 - 8.4.5
MY_CONSTANT integer $string string $num double $_GET array $_SERVER['PHP_SELF'] string

preferences:
154.96 ms | 408 KiB | 5 Q