Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to intentionally cause a fatal error in PHP script?

Tags:

php

crash

I want script to stop being executed at the point of the crash, while not to exhaust the memory or otherwise crash the server.

Any idea how to do that?

like image 892
Lafix Avatar asked Jul 08 '15 05:07

Lafix


1 Answers

I believe this is what you're looking for:

trigger_error("Oops!", E_USER_ERROR);

Docs: http://php.net/manual/en/function.trigger-error.php

E_USER_ERROR is pretty much equal to E_ERROR, which is a fatal runtime error.

like image 77
Michal Sukupčák Avatar answered Nov 01 '22 11:11

Michal Sukupčák