Is there any native PHP function which throws an b

2020-03-01 17:21发布

问题:

While answering PHP rename() doesn't throws exception on error I was wondering if there are any native PHP functions which throw a built-in Exception, beside the SPL stuff?

回答1:

Not really. If you read the note on that page you linked:

Note:

Internal PHP functions mainly use Error reporting, only modern Object oriented extensions use exceptions. However, errors can be simply translated to exceptions with ErrorException.



回答2:

PDO can be configured to throw exceptions



回答3:

PHP 5 has an exception model similar to that of other programming languages.

ErrorException