Home  >  Article  >  Backend Development  >  为什么空减空输出是0?

为什么空减空输出是0?

WBOY
WBOYOriginal
2016-06-23 13:41:53785browse

有一个表uuu,只有1条数据,如下:

$aaa = false;查询语句:'select * from uuu where id='.$aaa

执行这条查询返回的是false,还是' ',还是null,还是什么啊?
我试了这个:
$k = '' - '';$k = null - null;echo $k;

输出的都是0


回复讨论(解决方案)

$aaa=false;

$sql = 'select * from uuu where id='.$aaa;

var_dump($sql);

false 连接于字符串的时候  为空字符串 

输出为string(27) "select * from uuu where id="

上面的SQL  mysql 语法检测不通过  所以给你返回了false  表示查询失败

要看变量值,不要用echo,要用var_dump

您的查询指令返回空记录,所以无所谓 是false,还是' ',还是null

当记录集不为空,且字段值为 null 时,除 PDO 可以指定外,其他数据库函数都返回 ‘’(空字符串)

$aaa = false;
查询语句:'select * from uuu where id='.$aaa
返回空??,因??有匹配id=false的??。

$k = '' - '';
$k = null - null;
var_dump($k);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn