Home > Backend Development > PHP Tutorial > 在一个Class里throw一个Exception,运行一定被中断么,有没有在Controller里给catch回来的方法?

在一个Class里throw一个Exception,运行一定被中断么,有没有在Controller里给catch回来的方法?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:20:48
Original
1301 people have browsed it

如题:

在一个Class里throw一个Exception,运行一定被中断么,有没有在Controller里给catch回来的方法?

回复内容:

如题:

在一个Class里throw一个Exception,运行一定被中断么,有没有在Controller里给catch回来的方法?

应该不会,因为异常就是给一个机会去处理错误的,如果处理异常的话,就不会被中断
可以参考官方手册上的介绍:http://php.net/manual/zh/language.exceptions.php

在抛出异常的地方先catch异常,然后在catch里面人为的throw 异常,这样就可以异常往上层方法抛出了

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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
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