3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php var_dump(array_map(function($token) { if (is_array($token)) $token[0] = token_name($token[0]); return $token; }, token_get_all("<?php if (0 === 1) {} elseif (1 === 2) {} else {}"))); var_dump(array_map(function($token) { if (is_array($token)) $token[0] = token_name($token[0]); return $token; }, token_get_all("<?php if (0 === 1) {} else if (1 === 2) {} else {}")));
Output for 5.3.0 - 7.1.0
array(31) { [0]=> array(3) { [0]=> string(10) "T_OPEN_TAG" [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> string(4) "T_IF" [1]=> string(2) "if" [2]=> int(1) } [2]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [3]=> string(1) "(" [4]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "0" [2]=> int(1) } [5]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [6]=> array(3) { [0]=> string(14) "T_IS_IDENTICAL" [1]=> string(3) "===" [2]=> int(1) } [7]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [8]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "1" [2]=> int(1) } [9]=> string(1) ")" [10]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [11]=> string(1) "{" [12]=> string(1) "}" [13]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [14]=> array(3) { [0]=> string(8) "T_ELSEIF" [1]=> string(6) "elseif" [2]=> int(1) } [15]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [16]=> string(1) "(" [17]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "1" [2]=> int(1) } [18]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [19]=> array(3) { [0]=> string(14) "T_IS_IDENTICAL" [1]=> string(3) "===" [2]=> int(1) } [20]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [21]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "2" [2]=> int(1) } [22]=> string(1) ")" [23]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [24]=> string(1) "{" [25]=> string(1) "}" [26]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [27]=> array(3) { [0]=> string(6) "T_ELSE" [1]=> string(4) "else" [2]=> int(1) } [28]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [29]=> string(1) "{" [30]=> string(1) "}" } array(33) { [0]=> array(3) { [0]=> string(10) "T_OPEN_TAG" [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> string(4) "T_IF" [1]=> string(2) "if" [2]=> int(1) } [2]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [3]=> string(1) "(" [4]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "0" [2]=> int(1) } [5]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [6]=> array(3) { [0]=> string(14) "T_IS_IDENTICAL" [1]=> string(3) "===" [2]=> int(1) } [7]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [8]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "1" [2]=> int(1) } [9]=> string(1) ")" [10]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [11]=> string(1) "{" [12]=> string(1) "}" [13]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [14]=> array(3) { [0]=> string(6) "T_ELSE" [1]=> string(4) "else" [2]=> int(1) } [15]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [16]=> array(3) { [0]=> string(4) "T_IF" [1]=> string(2) "if" [2]=> int(1) } [17]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [18]=> string(1) "(" [19]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "1" [2]=> int(1) } [20]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [21]=> array(3) { [0]=> string(14) "T_IS_IDENTICAL" [1]=> string(3) "===" [2]=> int(1) } [22]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [23]=> array(3) { [0]=> string(9) "T_LNUMBER" [1]=> string(1) "2" [2]=> int(1) } [24]=> string(1) ")" [25]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [26]=> string(1) "{" [27]=> string(1) "}" [28]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [29]=> array(3) { [0]=> string(6) "T_ELSE" [1]=> string(4) "else" [2]=> int(1) } [30]=> array(3) { [0]=> string(12) "T_WHITESPACE" [1]=> string(1) " " [2]=> int(1) } [31]=> string(1) "{" [32]=> string(1) "}" }
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/Kh9j1 on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/Kh9j1 on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/Kh9j1 on line 3
Process exited with code 255.