while ($strpos = strpos($text, $search, $offset)) {
$offset = $strpos + $search_length .'<br>';
$text = substr_replace($text, $replace, $strpos, $search_length);
}
注意:在 C:''xampp 中遇到的格式不正确的数值。''index.php 在第 13 行
第 13 行是:while ($strpos = strpos($text, $search, $offset)) {
这是我定义变量的方式:
$text = $_POST['text'];
$search = $_POST['searchfor'];
$offset = 0;
真的找不到导致错误的地方。
代码现在做得很好,无法解释之前到底发生了什么。感谢您的回复。
尝试将其更改为:
while ($strpos = strpos($text, $search, $offset) !== false) {
...
}
不要与<br>
连接。 在下一个语句中回显br
。错误将消失
while($strpos = strpos($text, $search, $offset)) {
echo $offset= $strpos+$search_length;
echo '<br>';
}
我不喜欢回显新行,但如果我使用 $search_length
. 出现br
标记错误。我不知道为什么。