'Trigger fatal error in PHP 7 (non-exception)
I need to be able to trigger a fatal error in PHP 7 that is not thrown as an exception.
According to the PHP docs, most of the fatal errors have been converted to exceptions. However, I can't find any docs on which ones were and were not converted.
My Question: What is something I can do in PHP to trigger one of the fatal errors that has not been converted to an exception?
Reason: I am developing a universal error handler for an API based application. I need a test case to prove it will work as I say it does.
Solution 1:[1]
You can trigger a fatal in a number of ways, calling an undefined function is one such way and pretty simple, e.g.
<?php
foo();
<br />
<b>Fatal error</b>: Uncaught Error: Call to undefined function foo() in [...][...]:4
Stack trace:
#0 {main}
thrown in <b>[...][...]</b> on line <b>4</b><br />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | aland |
