PHP: Find php token in file without parsing entire file with token_get_all -


i need parse php file looking token.

it can easly done $tokens = token_get_all($filecontent); , looking required token in results array $tokens.

problem bigger files parsing takes around 0.15s while it's required token may somewhere in beginning of file - in such case lot of time lost parsing wasted.

is possible make kind of step step token parsing , stopping parsing when required token found?

$f = fopen("myfile.php", "r"); while ( ($line = fgets($f)) != null) {     $tokens = token_get_all ($line);     if (in_array ($searchedtoken, $tokens)) {         // job...         break;      } } fclose ($f); 

Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -