作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一小部分代码:
$company = array('relation' => $_SESSION['username']);
$companyresponse = $wcfclient->GetCompany($company);
foreach ($companyresponse->GetCompanyResult as $key => $value){
echo $value[0]; //This is the name of the company
if ($value[1] == TRUE){
echo "Company blocked";
}
elseif($value[1] == FALSE){
echo "Company NOT blocked";
}
echo $value[1]; //This gives me the correct result, in this case: FALSE
if ($value[1] == 1){
echo "Company blocked";
}
else{
echo "Company NOT blocked";
}
var_dump($value[1])
string(4) "True" Company blockedTrue
最佳答案
$value的类型1是“字符串”而不是“boolean ”。
When converting to boolean, the following values are considered FALSE:
the boolean FALSE itself
the integer 0 (zero)
the float 0.0 (zero)
the empty string, and the string "0"
an array with zero elements
an object with zero member variables (PHP 4 only)
the special type NULL (including unset variables)
SimpleXML objects created from empty tagsEvery other value is considered TRUE (including any resource).
if(strtoupper($value[1]) == "TRUE"){
//...
}else{
//...
}
关于php - 检查 boolean 值是真还是假,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17567026/
我是一名优秀的程序员,十分优秀!