Home > Backend Development > PHP Tutorial > How to catch exceptions in try catch of TP3.2

How to catch exceptions in try catch of TP3.2

巴扎黑
Release: 2016-11-10 09:39:40
Original
2717 people have browsed it

Java code

public function t(){
        try {
            throw new \Exception("haha");
        }catch (Exception $e){
            dump($e);
        }
         
    }
Copy after login

The above catch cannot be captured, and an ERROR page will appear. Because catch (Exception $e){ captures the Exception class of the current module, not Exception, so it needs to be changed to

Java code

public function t(){
        try {
           E("errr");
        }catch (\Exception $e){
            dump($e);
        }
    }
Copy after login


Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template