php 学习笔记--bool

来源:互联网 发布:网络安全员年薪多少 编辑:程序博客网 时间:2024/06/05 12:48
// someKey is a boolean true
$array = array('someKey'=>true);

// in the following 'false' string gets converted to a boolean true
if($array['someKey'] != 'false')
    echo 'The value of someKey is '.$array['someKey'];

As a result the above will output nothing :)

if($array['someKey'] == 'false')
    echo 'The value of someKey is '.$array['someKey'];

And the above will output
The value of someKey is 1

In short true == 'false' is true.

//以上引自php手册。


当 关键字 true 或者 false 在字符串里时,都只代表字符串,不再具有bool值特性。

输出布尔值时,true 已 1 输出; false 无输出。

0 0
原创粉丝点击