<?php
$source = <<<'code'
<?php
function system_update_10101(&$sandbox = NULL) {
}
code;
$tokens = token_get_all($source, TOKEN_PARSE);
foreach ($tokens as $token) {
if (is_array($token)) {
echo token_name($token[0]) , PHP_EOL;
}
}
var_dump($tokens[2]);
var_dump($tokens[4]);
- Output for 8.1.0 - 8.1.31, 8.2.0 - 8.2.27, 8.3.1, 8.3.3, 8.3.5 - 8.3.6, 8.3.8, 8.3.10, 8.3.12, 8.3.14, 8.4.1 - 8.4.2
- T_OPEN_TAG
T_WHITESPACE
T_FUNCTION
T_WHITESPACE
T_STRING
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
T_VARIABLE
T_WHITESPACE
T_WHITESPACE
T_STRING
T_WHITESPACE
T_WHITESPACE
T_WHITESPACE
array(3) {
[0]=>
int(310)
[1]=>
string(8) "function"
[2]=>
int(3)
}
array(3) {
[0]=>
int(262)
[1]=>
string(19) "system_update_10101"
[2]=>
int(3)
}
- Output for 8.3.0, 8.3.2, 8.3.4, 8.3.7, 8.3.9, 8.3.11, 8.3.13, 8.3.15
- T_OPEN_TAG
T_WHITESPACE
T_FUNCTION
T_WHITESPACE
T_STRING
T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG
T_VARIABLE
T_WHITESPACE
T_WHITESPACE
T_STRING
T_WHITESPACE
T_WHITESPACE
T_WHITESPACE
array(3) {
[0]=>
int(347)
[1]=>
string(8) "function"
[2]=>
int(3)
}
array(3) {
[0]=>
int(313)
[1]=>
string(19) "system_update_10101"
[2]=>
int(3)
}
- Output for 8.0.30
- T_OPEN_TAG
T_WHITESPACE
T_FUNCTION
T_WHITESPACE
T_STRING
T_VARIABLE
T_WHITESPACE
T_WHITESPACE
T_STRING
T_WHITESPACE
T_WHITESPACE
T_WHITESPACE
array(3) {
[0]=>
int(310)
[1]=>
string(8) "function"
[2]=>
int(3)
}
array(3) {
[0]=>
int(262)
[1]=>
string(19) "system_update_10101"
[2]=>
int(3)
}
- Output for 8.0.1 - 8.0.29
- T_OPEN_TAG
T_WHITESPACE
T_FUNCTION
T_WHITESPACE
T_STRING
T_VARIABLE
T_WHITESPACE
T_WHITESPACE
T_STRING
T_WHITESPACE
T_WHITESPACE
T_WHITESPACE
array(3) {
[0]=>
int(345)
[1]=>
string(8) "function"
[2]=>
int(3)
}
array(3) {
[0]=>
int(311)
[1]=>
string(19) "system_update_10101"
[2]=>
int(3)
}
preferences:
69.58 ms | 411 KiB | 5 Q