3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $tokens = token_get_all('<?php $a = 1 + 2; echo $a ?>'); foreach($tokens as $token) { var_dump($token); echo token_name($token[0]); }
Output for 7.0.0 - 7.1.0
array(3) { [0]=> int(379) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(320) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(317) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(317) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(328) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(320) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(381) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for hhvm-3.10.0 - 3.12.0
array(3) { [0]=> int(368) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be integer, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(316) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(370) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.6.0 - 5.6.28
array(3) { [0]=> int(376) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(312) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(308) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(308) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(319) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(312) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(378) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.5.0 - 5.5.36
array(3) { [0]=> int(374) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(310) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(306) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(306) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(317) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(310) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(377) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(376) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.4.0 - 5.4.45
array(3) { [0]=> int(372) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(316) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(375) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(374) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.3.0 - 5.3.29
array(3) { [0]=> int(368) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(316) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(370) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.2.2 - 5.2.17
array(3) { [0]=> int(367) [1]=> string(6) "<?php " [2]=> int(1) } T_OPEN_TAGarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "1" [2]=> int(1) } T_LNUMBERarray(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(305) [1]=> string(1) "2" [2]=> int(1) } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(316) [1]=> string(4) "echo" [2]=> int(1) } T_ECHOarray(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(309) [1]=> string(2) "$a" [2]=> int(1) } T_VARIABLEarray(3) { [0]=> int(370) [1]=> string(1) " " [2]=> int(1) } T_WHITESPACEarray(3) { [0]=> int(369) [1]=> string(2) "?>" [2]=> int(1) } T_CLOSE_TAG
Output for 5.1.0 - 5.2.1
array(2) { [0]=> int(367) [1]=> string(6) "<?php " } T_OPEN_TAGarray(2) { [0]=> int(309) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(305) [1]=> string(1) "1" } T_LNUMBERarray(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(305) [1]=> string(1) "2" } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(316) [1]=> string(4) "echo" } T_ECHOarray(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(309) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(370) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(369) [1]=> string(2) "?>" } T_CLOSE_TAG
Output for 5.0.0 - 5.0.5
array(2) { [0]=> int(365) [1]=> string(6) "<?php " } T_OPEN_TAGarray(2) { [0]=> int(308) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(304) [1]=> string(1) "1" } T_LNUMBERarray(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(304) [1]=> string(1) "2" } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(315) [1]=> string(4) "echo" } T_ECHOarray(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(308) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(368) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(367) [1]=> string(2) "?>" } T_CLOSE_TAG
Output for 4.4.2 - 4.4.9
array(2) { [0]=> int(354) [1]=> string(6) "<?php " } T_OPEN_TAGarray(2) { [0]=> int(307) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(303) [1]=> string(1) "1" } T_LNUMBERarray(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(303) [1]=> string(1) "2" } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(314) [1]=> string(4) "echo" } T_ECHOarray(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(307) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(357) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(356) [1]=> string(2) "?>" } T_CLOSE_TAG
Output for 4.3.0 - 4.4.1
array(2) { [0]=> int(353) [1]=> string(6) "<?php " } T_OPEN_TAGarray(2) { [0]=> int(306) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEstring(1) "=" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(302) [1]=> string(1) "1" } T_LNUMBERarray(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEstring(1) "+" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(302) [1]=> string(1) "2" } T_LNUMBERstring(1) ";" Warning: token_name() expects parameter 1 to be long, string given in /in/dN9Bs on line 7 array(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(313) [1]=> string(4) "echo" } T_ECHOarray(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(306) [1]=> string(2) "$a" } T_VARIABLEarray(2) { [0]=> int(356) [1]=> string(1) " " } T_WHITESPACEarray(2) { [0]=> int(355) [1]=> string(2) "?>" } T_CLOSE_TAG