How to catch undefined functions with set_error_handler in PHP

后端 未结 6 486
一整个雨季
一整个雨季 2021-02-05 19:47

I\'m taking the leap: my PHP scripts will ALL fail gracefully!

At least, that\'s what I\'m hoping for...`

I don\'t want to wrap (practically) every single line i

6条回答
  •  太阳男子
    2021-02-05 20:42

    Why isn't my custom error handler catching undefinedd functions? Are there other problems that this will cause?

    At a guess, I'd say that undefined function errors travel through a different execution path than other error types. Perhaps the PHP designers could tell you more, except I doubt PHP is in any way designed.

    If you'd like your scripts to fail gracefully while still writing them PHP-style, try putting the entire page in a function and then call it within a try..catch block.

提交回复
热议问题