我的问题主要是关于“while条件”,当在shuld返回“FALSE”时显然返回“TRUE”。这是代码:
<?php
$sentence='is is is';
$search='is';
$length=strlen($search);
$offset=0;
$j=1;
while(($pos = strpos($sentence,$search,$offset)) !==FALSE)
{
echo $j.'. '.$pos.'<br>';
$offset += $length;
$j++;
}
?>
返回:
- 0
- 3
- 6
醇>
拳头结果的显示证明是0,这是假的吗?为什么“while循环”中的代码操作完全相同?
答案 0 :(得分:2)
拳头结果的显示证明为0,为FALSE
我认为你是误导,0是is
第一次出现的位置而不是布尔值0
$sentence='is is is';
^ ^ ^
0 3 6