You need to catch an exception in your code, using the
catch(Exception $e)
Invalid, but changed to
catch(\Exception $e)
We can. Probably know what the namespace is about, but the specific is not very clear, ask for answers. In addition, it is used to find other exceptions in this file.
(Exception $e)
Rather than
(\Exception $e)
Reply content:
You need to catch an exception in your code that is catch(Exception $e)
invalid, but catch(\Exception $e)
you can change it. Probably know what the namespace is about, but the specific is not very clear, ask for answers. In addition, it is found that other exceptions in this file are used (Exception $e)
rather than(\Exception $e)
If your PHP file defines a namespace, then the class usage below the namespace must add \
Represents the root space, which is PHP's own class, not the class in your PHP file
The reason for the inability to catch may be that because the thrown exception does not match, check that exception classes thrown by other exceptions are passed through a layer of inheritance:
The fans are right about the situation.
If your PHP file defines a namespace, it catch(Exception $e)
looks for the exception class under that namespace, and if undefined, there is a problem with the class not found.
catch(\Exception $e)
Represents the root space, and this class is always present.
It is recommended to take a look at modern php
this book.
Exception represents the root namespace, which is the official PHP exception class, not add the words may be your current definition of the class under the namespace