php列表函数未在循环外回显变量
知道为什么我不能在循环外回显$a吗?我错过了什么php列表函数未在循环外回显变量,php,Php,知道为什么我不能在循环外回显$a吗?我错过了什么 while (list($a) = $db->fetch_array($query)) { $b = $a; //where $a = 10 } echo $a; //this echo's nothing. echo $b; //this echo's 10 当while循环结束时,$a重置为NULL,因此它不输出任何内容。(此时不再进入循环,因此不再执行$b=$a) 这是因为$db->fetch_array()在没有剩余行
while (list($a) = $db->fetch_array($query))
{
$b = $a; //where $a = 10
}
echo $a; //this echo's nothing.
echo $b; //this echo's 10
当while循环结束时,
$a
重置为NULL
,因此它不输出任何内容。(此时不再进入循环,因此不再执行$b=$a
)
这是因为$db->fetch_array()
在没有剩余行时返回false