Home > Backend Development > PHP Tutorial > 初学PHP,有一个有关问题

初学PHP,有一个有关问题

WBOY
Release: 2016-06-13 11:56:21
Original
821 people have browsed it

初学PHP,有一个问题
看书上写了一些检验变量数据类型的函数,就试了试其中的一个

<br />$a = 5;<br />    echo is_int($a);<br />
Copy after login

为什么打印的是1,a是一个整形变量,不应该返回true吗?
------解决方案--------------------
$a = 5;<br />echo is_int($a); //1<br />var_dump(is_int($a)); //bool(true)<br />
Copy after login

true 转换为数值时就是 1
------解决方案--------------------
1为真 真就是true ,0为假 假就是false
------解决方案--------------------
你echo 就输出1 你var_dump就是true了!
------解决方案--------------------
<br />   $a = 5;<br />    echo var_dump(is_int($a));<br /><br />
Copy after login

------解决方案--------------------
据说PHP源码中一个echo是经过10多层调用的,实在没echo过布尔值,估计是强制转成整数了
------解决方案--------------------
整型 bool true = 1 false = 0

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template