【发布时间】:2014-11-08 00:51:03
【问题描述】:
我的问题主要是关于一个“while 条件”,它在应该返回“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 !== FALSE.
标签: php while-loop strpos