### && 和 ||
* * * * *
常用于比if还简单的原句
//如果bool真,则$string='test';
$bool && $string = 'test';
//if
if ($bool) {
$string = 'test';
}
//如果bool假,则$string='test';
$bool || $string = 'test';
if (!$bool) {
$string = 'test';
}
//如果bool假,调用方法弹出
if (!$bool) {
$this->alert('error');
}
缺点:无法与return,throw new Exception连用;
框架解决方法,类中定义exception函数解决
>
> private function exception(string $message) : void {
> throw new Exception($message);
> }
>



