error handling - What is the best way to define an autoloader function in PHP that can show which line caused it to be called when it can't find a class? -


atm have simple autoloader converts underscores front slashes , sticks on .php @ end. naturally requires add "app dir" include path.

the problem appears when attempt use class cannot found. in case php emit measly warnings , errors point autoloader function source.

what easiest way find out line in file caused autoloader attempt load missing class?

add this:

if (!file_exists($class.'.php')) {   echo '<pre>';   debug_print_backtrace();   echo '</pre>'; } 

or more detailed:

if (!file_exists($class.'.php')) {   // pseudo code!   echo '<pre>';   $debug = debug_backtrace();   echo 'line: '.$debug['line'];   echo '</pre>'; } 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -