I like to use the PHP Error class to return using throw like this:
throw new Error('Some problem description');
Sadly, I have to use PHP 5.4.16 on CentOS 7.5. The Error class was introduced in PHP 7.
Is there a class that I can include which emulates the behavior of the Error class from PHP 7?
Error and Exception have the same exact signature so you can possibly use the latter:
Demo
Tweak for you liking. For instance, you may want to check PHP version (it's possible that software written for PHP/5 already has a custom
Errorclass). Of course, no native function is going to actually throw it.