PHP中 false 当作数组来处理,没有报错或警告。
下面的例子,用于测试:使用mysql_fetch_row或者mysql_fetch_array函数,当没有找到行数据时,返回false。这是将返回不进行操作,而是当作数组继续操作,没有提示警告。谁知道为什?
<?php
header("Content-Type:text/html; content=utf-8");
try{
$link= mysql_connect('localhost','root','');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db('test', $link) or die ('Can\'t use foo : ' . mysql_error());
}
catch(Exception $e){
echo $e->getMessage();
}
$sql="select * from daily_work";
$result = mysql_query($sql);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
//如果没有找到更多行,则返回false
$row = mysql_fetch_row($result);
echo gettype($row['uuid']); //返回NULL对象
if(NULL ==0){ //true
echo 123;
}
if(NULL == false){ //true
echo 234;
}
if(NULL === 0 ){ //false
echo 345;
}
?>