<?php
$text = <<<TXT
<?php
namespace AAA;
require_once '/tmp/dev2/t4.php';
class AAA {
}
\$class = new AAA();
TXT;
$tokens = token_get_all($text);
foreach ($tokens as $token) {
echo json_encode($token) . "\n";
}
- Output for 8.4.1 - 8.4.14
- [393,"<?php\n",1]
[396,"\n",2]
[342,"namespace",3]
[396," ",3]
[262,"AAA",3]
";"
[396,"\n\n",3]
[276,"require_once",5]
[396," ",5]
[269,"'\/tmp\/dev2\/t4.php'",5]
";"
[396,"\n",5]
[336,"class",6]
[396," ",6]
[262,"AAA",6]
[396," ",6]
"{"
[396,"\n",6]
"}"
[396,"\n\n",7]
[266,"$class",9]
[396," ",9]
"="
[396," ",9]
[284,"new",9]
[396," ",9]
[262,"AAA",9]
"("
")"
";"
- Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 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.3.16, 8.3.18 - 8.3.19, 8.3.21, 8.3.23 - 8.3.26
- [389,"<?php\n",1]
[392,"\n",2]
[339,"namespace",3]
[392," ",3]
[262,"AAA",3]
";"
[392,"\n\n",3]
[276,"require_once",5]
[392," ",5]
[269,"'\/tmp\/dev2\/t4.php'",5]
";"
[392,"\n",5]
[333,"class",6]
[392," ",6]
[262,"AAA",6]
[392," ",6]
"{"
[392,"\n",6]
"}"
[392,"\n\n",7]
[266,"$class",9]
[392," ",9]
"="
[392," ",9]
[284,"new",9]
[392," ",9]
[262,"AAA",9]
"("
")"
";"
- 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, 8.3.17, 8.3.20, 8.3.22
- [394,"<?php\n",1]
[397,"\n",2]
[375,"namespace",3]
[397," ",3]
[313,"AAA",3]
";"
[397,"\n\n",3]
[263,"require_once",5]
[397," ",5]
[320,"'\/tmp\/dev2\/t4.php'",5]
";"
[397,"\n",5]
[369,"class",6]
[397," ",6]
[313,"AAA",6]
[397," ",6]
"{"
[397,"\n",6]
"}"
[397,"\n\n",7]
[317,"$class",9]
[397," ",9]
"="
[397," ",9]
[324,"new",9]
[397," ",9]
[313,"AAA",9]
"("
")"
";"
preferences:
83.24 ms | 411 KiB | 5 Q