How to catch exceptions in try catch of TP3.2

巴扎黑
Release: 2016-11-10 09:39:40
Original
2639 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:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!