3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $source = <<<'code' <?php namespace aaa\sdfsd; class A { const PUBLIC = 1; } code; $tokens = token_get_all($source); var_dump($tokens); foreach ($tokens as $token) { if (is_array($token)) { echo token_name($token[0]) , PHP_EOL; } }
based on uqtWk
Output for 7.0.0 - 7.1.0, 7.1.20 - 7.3.1
array(24) { [0]=> array(3) { [0]=> int(379) [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> int(388) [1]=> string(9) "namespace" [2]=> int(2) } [2]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(2) } [3]=> array(3) { [0]=> int(319) [1]=> string(3) "aaa" [2]=> int(2) } [4]=> array(3) { [0]=> int(390) [1]=> string(1) "\" [2]=> int(2) } [5]=> array(3) { [0]=> int(319) [1]=> string(5) "sdfsd" [2]=> int(2) } [6]=> string(1) ";" [7]=> array(3) { [0]=> int(382) [1]=> string(2) " " [2]=> int(2) } [8]=> array(3) { [0]=> int(361) [1]=> string(5) "class" [2]=> int(4) } [9]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(4) } [10]=> array(3) { [0]=> int(319) [1]=> string(1) "A" [2]=> int(4) } [11]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(4) } [12]=> string(1) "{" [13]=> array(3) { [0]=> int(382) [1]=> string(5) " " [2]=> int(5) } [14]=> array(3) { [0]=> int(347) [1]=> string(5) "const" [2]=> int(6) } [15]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [16]=> array(3) { [0]=> int(316) [1]=> string(6) "PUBLIC" [2]=> int(6) } [17]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [18]=> string(1) "=" [19]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [20]=> array(3) { [0]=> int(317) [1]=> string(1) "1" [2]=> int(6) } [21]=> string(1) ";" [22]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [23]=> string(1) "}" } T_OPEN_TAG T_NAMESPACE T_WHITESPACE T_STRING T_NS_SEPARATOR T_STRING T_WHITESPACE T_CLASS T_WHITESPACE T_STRING T_WHITESPACE T_WHITESPACE T_CONST T_WHITESPACE T_PUBLIC T_WHITESPACE T_WHITESPACE T_LNUMBER T_WHITESPACE
Output for 7.1.1 - 7.1.10
array(24) { [0]=> array(3) { [0]=> int(379) [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> int(388) [1]=> string(9) "namespace" [2]=> int(2) } [2]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(2) } [3]=> array(3) { [0]=> int(319) [1]=> string(3) "aaa" [2]=> int(2) } [4]=> array(3) { [0]=> int(390) [1]=> string(1) "\" [2]=> int(2) } [5]=> array(3) { [0]=> int(319) [1]=> string(5) "sdfsd" [2]=> int(2) } [6]=> string(1) ";" [7]=> array(3) { [0]=> int(382) [1]=> string(2) " " [2]=> int(2) } [8]=> array(3) { [0]=> int(361) [1]=> string(5) "class" [2]=> int(4) } [9]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(4) } [10]=> array(3) { [0]=> int(319) [1]=> string(1) "A" [2]=> int(4) } [11]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(4) } [12]=> string(1) "{" [13]=> array(3) { [0]=> int(382) [1]=> string(5) " " [2]=> int(5) } [14]=> array(3) { [0]=> int(347) [1]=> string(5) "const" [2]=> int(6) } [15]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [16]=> array(3) { [0]=> int(311) [1]=> string(6) "PUBLIC" [2]=> int(6) } [17]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [18]=> string(1) "=" [19]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [20]=> array(3) { [0]=> int(317) [1]=> string(1) "1" [2]=> int(6) } [21]=> string(1) ";" [22]=> array(3) { [0]=> int(382) [1]=> string(1) " " [2]=> int(6) } [23]=> string(1) "}" } T_OPEN_TAG T_NAMESPACE T_WHITESPACE T_STRING T_NS_SEPARATOR T_STRING T_WHITESPACE T_CLASS T_WHITESPACE T_STRING T_WHITESPACE T_WHITESPACE T_CONST T_WHITESPACE T_PUBLIC T_WHITESPACE T_WHITESPACE T_LNUMBER T_WHITESPACE
Output for hhvm-3.15.4
array(24) { [0]=> array(3) { [0]=> int(368) [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> int(377) [1]=> string(9) "namespace" [2]=> int(2) } [2]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(2) } [3]=> array(3) { [0]=> int(307) [1]=> string(3) "aaa" [2]=> int(2) } [4]=> array(3) { [0]=> int(380) [1]=> string(1) "\" [2]=> int(2) } [5]=> array(3) { [0]=> int(307) [1]=> string(5) "sdfsd" [2]=> int(2) } [6]=> string(1) ";" [7]=> array(3) { [0]=> int(371) [1]=> string(2) " " [2]=> int(2) } [8]=> array(3) { [0]=> int(353) [1]=> string(5) "class" [2]=> int(4) } [9]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(4) } [10]=> array(3) { [0]=> int(307) [1]=> string(1) "A" [2]=> int(4) } [11]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(4) } [12]=> string(1) "{" [13]=> array(3) { [0]=> int(371) [1]=> string(5) " " [2]=> int(5) } [14]=> array(3) { [0]=> int(335) [1]=> string(5) "const" [2]=> int(6) } [15]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(6) } [16]=> array(3) { [0]=> int(342) [1]=> string(6) "PUBLIC" [2]=> int(6) } [17]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(6) } [18]=> string(1) "=" [19]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(6) } [20]=> array(3) { [0]=> int(305) [1]=> string(1) "1" [2]=> int(6) } [21]=> string(1) ";" [22]=> array(3) { [0]=> int(371) [1]=> string(1) " " [2]=> int(6) } [23]=> string(1) "}" } T_OPEN_TAG T_NAMESPACE T_WHITESPACE T_STRING T_NS_SEPARATOR T_STRING T_WHITESPACE T_CLASS T_WHITESPACE T_STRING T_WHITESPACE T_WHITESPACE T_CONST T_WHITESPACE T_PUBLIC T_WHITESPACE T_WHITESPACE T_LNUMBER T_WHITESPACE
Output for 5.6.0 - 5.6.30
array(24) { [0]=> array(3) { [0]=> int(376) [1]=> string(6) "<?php " [2]=> int(1) } [1]=> array(3) { [0]=> int(385) [1]=> string(9) "namespace" [2]=> int(2) } [2]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(2) } [3]=> array(3) { [0]=> int(310) [1]=> string(3) "aaa" [2]=> int(2) } [4]=> array(3) { [0]=> int(388) [1]=> string(1) "\" [2]=> int(2) } [5]=> array(3) { [0]=> int(310) [1]=> string(5) "sdfsd" [2]=> int(2) } [6]=> string(1) ";" [7]=> array(3) { [0]=> int(379) [1]=> string(2) " " [2]=> int(2) } [8]=> array(3) { [0]=> int(358) [1]=> string(5) "class" [2]=> int(4) } [9]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(4) } [10]=> array(3) { [0]=> int(310) [1]=> string(1) "A" [2]=> int(4) } [11]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(4) } [12]=> string(1) "{" [13]=> array(3) { [0]=> int(379) [1]=> string(5) " " [2]=> int(5) } [14]=> array(3) { [0]=> int(338) [1]=> string(5) "const" [2]=> int(6) } [15]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(6) } [16]=> array(3) { [0]=> int(347) [1]=> string(6) "PUBLIC" [2]=> int(6) } [17]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(6) } [18]=> string(1) "=" [19]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(6) } [20]=> array(3) { [0]=> int(308) [1]=> string(1) "1" [2]=> int(6) } [21]=> string(1) ";" [22]=> array(3) { [0]=> int(379) [1]=> string(1) " " [2]=> int(6) } [23]=> string(1) "}" } T_OPEN_TAG T_NAMESPACE T_WHITESPACE T_STRING T_NS_SEPARATOR T_STRING T_WHITESPACE T_CLASS T_WHITESPACE T_STRING T_WHITESPACE T_WHITESPACE T_CONST T_WHITESPACE T_PUBLIC T_WHITESPACE T_WHITESPACE T_LNUMBER T_WHITESPACE