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

How to catch exceptions in try catch of TP3.2

巴扎黑
巴扎黑Original
2016-11-10 09:39:402607browse

Java code

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

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);
        }
    }


Statement:
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
Previous article:php Redis storage sessionNext article:php Redis storage session