php中的非条件语句while循环括号!? [英] non conditional statement inside php while loop parentheses !?

查看:68
本文介绍了php中的非条件语句while循环括号!?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



请查看以下代码:



Hello everybody,

Please take look at the following code:

<?php
   $numberedString = "1234567890123456789012345678901234567890";
$offset = 0; // initial offset is 0
$fiveCounter = 0;

// First check if there is a "5" at position 0.
if(strpos($numberedString, "5") == 0){
  $fiveCounter++;
    echo "<br />Five #$fiveCounter is at position - 0";
}

// Check the rest of the string for 5's
while($offset = strpos($numberedString, "5", $offset + 1)){
    $fiveCounter++;
    echo "<br />Five #$fiveCounter is at position - $offset";
}
?>





here while循环括号中的语句不是条件的(因为它不返回布尔值),但是这段代码是如何工作的?



here the statement inside while loop parentheses is not conditional(because it does not return boolean value),but how does this code works well?

推荐答案

numberedString = 1234567890123456789012345678901234567890;
numberedString = "1234567890123456789012345678901234567890";


offset = 0 ; // 初始偏移量为0
offset = 0; // initial offset is 0


fiveCounter = 0 ;

// 首先检查位置0是否有5。
if(strpos(
fiveCounter = 0; // First check if there is a "5" at position 0. if(strpos(


这篇关于php中的非条件语句while循环括号!?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆