🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### && 和 || * * * * * 常用于比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); > } > ~~~