Search code examples
phpfatal-error

PHP: Trigger fatal error?


I would like to be able to throw a fatal, uncatchable error in my php class when a user of my class abuses it for something I did not intend. I don't want him/her to be able to recover with a catch clause. I know about trigger_error, but I can only make it issue warnings or notices.


Solution

  • E_USER_ERROR is the suited constant.

    trigger_error("Fatal error", E_USER_ERROR);
    

    See also the first example of the manual page and the list of PHP Errors (only ones beginning with E_USER* may be issued from trigger_error).