Blogger Information
Blog 12
fans 0
comment 0
visits 6622
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
boolean布尔类型-php学习第二课
虎哥的学习日志
Original
556 people have browsed it

boolean布尔类型

TRUE FALSE,不区分大小写 true false;

$is_ok = true;

echo gettype($is_ok);

//布尔值类型主要应用于流程控制

if($is_ok){

    echo "OK";

}else{

    echo "Bad";

}

//哪些数据类型可以直接转换为布尔值false?

var_dump((bool)0);//0    false

var_dump((bool)''); //空字符串    false

var_dump((bool)null);//null    false

var_dump((bool)'0');//'0'    false

var_dump((bool)'00');//'00'    true 

var_dump((bool)'0.0');//'0.0'    true     证明单字符的0 转化为false,多字符皆为true;

var_dump((boo)[]);//空数组    false

其余的都为true; 

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post