【发布时间】:2023-03-05 02:18:01
【问题描述】:
我写了一个函数,成功返回数据,失败返回假。
我想知道这是否被认为是评估 php 中返回值的正确方法。
function data(){
if($all_is_good){
return $data
}else{
return false;
}
}
$data = data(); //basically either a long series of strings or arrays
if(!$data){ //<-- this is the line I'm concerned about, is it safe to assume this?
echo 'oh no, bad stuff happened';
}
非常感谢!
【问题讨论】:
标签: php conditional boolean