Lafix Lafix - 1 month ago 8
PHP Question

How to intentionally cause a fatal error in PHP script?

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?

Answer

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.