An Exception needs to be caught in the code. The catch (Exception $ e) is invalid, but it can be changed to catch (Exception $ e. It probably depends on what the namespace is, but it is not very clear. In addition, it is found that all other exceptions used in this file are used (E... an exception needs to be caught in the code, use
catch(Exception $e)
Invalid, but changed
catch(\Exception $e)
You can. It probably depends on what the namespace is, but it is not very clear. In addition, it is found that all other exceptions used in this file are used.
(Exception $e)
Rather
(\Exception $e)
Reply content:
Capture an exception in the code. usecatch(Exception $e)
Invalid, but changedcatch(\Exception $e)
You can. It probably depends on what the namespace is, but it is not very clear. In addition, it is found that all other exceptions used in this file are used.(Exception $e)
Rather(\Exception $e)
If your php file defines a namespace, the class usage under the namespace must be added \
Indicates the root space, that is, the php class, not the class in your php file.
The cause that cannot be captured may cause the thrown exception to be mismatched. check whether the exception classes thrown by other exceptions pass through an inheritance relationship ..
Fans are right.
If your php file defines a namespace,catch(Exception $e)
The Exception class under the namespace will be searched. if undefined, the class will not be found.
catch(\Exception $e)
Indicates the root space. this class always exists.
Let's take a look.modern php
This book.
Exception indicates the root namespace. to put it bluntly, it is the official Exception tired class of php. if it is not added, it may be the class under the namespace you currently define.