while loop in php with assignment operator

前端 未结 7 723
闹比i
闹比i 2020-12-17 10:41

the code I\'m looking at does this...

while ($info=mysql_fetch_array($data_jurisdiction))
{
//some stuff
}

I\'m wondering what does this wh

7条回答
  •  暖寄归人
    2020-12-17 11:05

    great answer from hakre. what is said is that

    while ($info=mysql_fetch_array($data_jurisdiction))
    

    will execute in the same way as this

    while (mysql_fetch_array($data_jurisdiction)==true)
    

    or even this

    $info = mysql_fetch_array($data_jurisdiction);
    if($info==true)
    

    so keep in mind that if mysql_fetch_array($data_jurisdiction) returns anything that can be evaluated to false, the assignment won't work. some of those values are (and I know I will forget a few:

    • 0
    • "0"
    • false
    • "false"
    • NULL
    • ""
    • array() (not fully sure about this one)

提交回复
热议问题