laravel 避免不存在的对象调用方法或属性报错的函数是什么来着?
$a = Record::first();
$a->toJson();
Call to a member function toJson() on null
在论坛看到过一个函数可以避免抛出异常,是什么来着
抱歉记错了,不是 php 中的方法,是 laravel 中的 $res = optional ($a)->toJson ();$a 不存在时 $res 返回 null
推荐文章: