How to catch error of require() or include() in PHP?

前端 未结 6 1019
甜味超标
甜味超标 2020-12-08 15:33

I\'m writing a script in PHP5 that requires the code of certain files. When A file is not available for inclusion, first a warning and then a fatal error are thrown. I\'d li

6条回答
  •  自闭症患者
    2020-12-08 16:27

    I would suggest you took a look at the most recent comment in the documentation for the set_error_handler() function.

    It suggests the following as a method (and with an example) of catching fatal errors:

     
    

    I haven't tried the suggestion, but this could propably be used in other fatal error scenarios.

提交回复
热议问题