您的位置:首页 > 编程语言 > PHP开发

php 学习笔记--bool

2015-10-23 17:02 609 查看
// 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 无输出。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  PHP