Set_error_handler function that does not cause autoload

I have a set_error_handler() function to call a function when there is an error.

In this function, I have my own implementation of the exception class:

 function acs_error_handler($errno, $errstr, $errfile, $errline) { throw new acs_exception($errstr, $errno); } 

This gives me the following error:

Fatal error: Class 'acs_exception' not found

For some reason, this function does not call my startup function, which I installed using:

 spl_autoload_register('__autoload'); 

If I add the line:

 __autoload('acs_exception'); 

before calling the class in the error function, it all works.

My question is: should the __autoload() function fail when I call the acs_exception class in the error start function?

+4
source share
2 answers

Here is the related PHP error report .

Your error is triggered at compile time, which disables startup (and spl_autoload at the same time).

It will not be fixed for PHP5.3, because it can cause many other problems.

+3
source

This has been fixed in PHP 5.4.21 - now SPL startup functions are also launched from error handling functions! :)

+1
source

All Articles