我是一名初级 C 程序员。我最近开始学习 PHP 和 MySQL,并在 while 循环中遇到了这个有趣的行为:
while ($pages = mysql_fetch_array($pages_set))
{statement}
我之前了解到必须在循环中的某处(或表达式本身)更改条件才能使循环成为有限的,但在这种情况下我看不到它。
我研究了一下 mysql_fetch_array() 函数并找到了 this :
Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.
是否说指针在行中移动,到达末尾时返回0或NULL?
最佳答案
每次迭代时,指针都会移动到记录集中的下一行,因此当没有剩余数据时,$pages 将为 NULL,循环将结束。
关于php - 是什么改变了循环 : while (mysql_fetch_array($var))? 中的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11738636/