Why does `catch (Exception $e)` not handle this `ErrorException`?

夙愿已清 提交于 2019-12-04 22:53:14

I suspect that you need to write this:

try {
    static::$function_name($url);
} catch (\Exception $e) {}

Note the \ in front of Exception.

When you have declared a namespace, you need to specify the root namespace in front of classes like Exception, otherwise the catch block here will be looking for \Your\Namespace\Exception, and not just \Exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!