我在第3行的
PHP代码中收到此错误,可能是错误的?此代码已从PHP手册
user notes by frank at interactinet dot com中获取
<?PHP public function myMethod() { return 'test'; } public function myOtherMethod() { return null; } if($val = $this->myMethod()) { // $val might be 1 instead of the expected 'test' } if( ($val = $this->myMethod()) ) { // now $val should be 'test' } // or to check for false if( !($val = $this->myMethod()) ) { // this will not run since $val = 'test' and equates to true } // this is an easy way to assign default value only if a value is not returned: if( !($val = $this->myOtherMethod()) ) { $val = 'default' } ?>