说,
$obj = $this->someFunc(); // this returns an object
if(empty($obj)){
// suppose $obj is null, it does works correctly
}
Run Code Online (Sandbox Code Playgroud)
在http://php.net/manual/en/function.empty.php中,empty()仅用于变量和数组.
但是,这是正确的方法吗?