string - strpos function issue in PHP not finding the needle -
in php have open .php file , want evaluate lines. when $table_id , $line variables assigned value.
within text file have:
... $table_id = 'crs_class'; // table name $screen = 'crs_class.detail.screen.inc'; // file identifying screen structure ...
amongst other lines. if statement below never detects occurance of $table_id
or $screen
(even without $ prepended). can't understand why won't work strpos statement below looking 'require' works fine.
so, why isn't if statement getting hit?
while ($line=fgets($fh)) { //echo "evaluating... $line <br>"; **if ((($pos = stripos($line, '$table_id')) === true) || (($pos = stripos($line, '$screen'))===true))** { // todo: not evaluating tableid , screen lines correctly fix. // set $table_id , $screen variables task scripts eval($line); } if (($pos=stripos($line, 'require')) === true) { $controller = $line; } }
use !==false instead of ===true
stripos returns position integer if needle found. , that's never ===bool.
might interested in php's tokenizer module or lexer package in pear repository.
Comments
Post a Comment