PHPで私は.phpファイルを開き、特定の行を評価したいと思います。特に、$ table_id変数と$ line変数に値が割り当てられている場合PHPでstrpos関数の問題が針を見つけられない
私が持っているテキストファイル内:他の行の中で
...
$table_id = 'crs_class'; // table name
$screen = 'crs_class.detail.screen.inc'; // file identifying screen structure
...
。下記のifステートメントは、$table_id
または$screen
の出現を検出することはありません($プリペンドされていなくても)。私はなぜそれがうまく動作するために '必要な'を探してstrposステートメントとして動作しません理解できません。
なぜこのif文がヒットしないのですか?
while ($line=fgets($fh)) {
//echo "Evaluating... $line <br>";
**if ((($pos = stripos($line, '$table_id')) === true) || (($pos = stripos($line, '$screen'))===true))**
{
// TODO: Not evaluating tableid and screen lines correctly fix.
// Set $table_id and $screen variables from task scripts
eval($line);
}
if (($pos=stripos($line, 'require')) === true) {
$controller = $line;
}
}
私はphp.netのマニュアルを誤解しています。 次の点に注意してください。 この関数は、Boolean FALSEを返すことがありますが、0または ""などFALSEと評価されるブール値でない値も返します。この関数の戻り値をテストするには、===演算子を使用します。彼は $ table_idが変数の値を見ていない、ファイル内のリテラル $ table_idがを探している - は、それが –