我有这个代码
<?php
$isi = $a['isi'];
$keyword = $_GET['tbSearch'];
$index = strpos("Ut varius consectetur tellus, id hendrerit neque auctor vel.","id");
echo "<h4>".$index."</h4>"
?>
输出为"30"
现在,我有另一个代码
<?php
$isi = $a['isi'];//from database
$keyword = $_GET['tbSearch'];//query string
$index = strpos($isi,$keyword);
echo "<h4>".$index."</h4>"
?>
但是输出是空的。知道吗?
根据注释,如果您不想匹配大小写,则必须使用 stripos,否则 strpos 将返回 false。