Re: strange autoload behavior

From: Date: Thu, 10 Jul 2008 04:54:18 +0000
Subject: Re: strange autoload behavior
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-38887@lists.php.net to get a copy of this message
Hi Gergely: > foo.php: > <?php > throw new Exception(); > class foo {} > > bar.php: > <?php > class bar extends foo {} > > <?php > function __autoload($className) > { > include $className.'.php'; > } > function error_handler() > { > throw new Exception(); > } > set_error_handler("error_handler"); > new bar(); > --------------------------------------------- > Result: "Fatal error: Class 'bar' not found". The fact that the class "bar" is not found indicates that your include in the autoload is either totally failing or gathering some other files. Make your life better by specifying the path in the include statement rather than relying on the include_path. Also, you would have known this on your own if you better utilized the error handler: function error_handler($errno, $errstr, $errfile, $errline) { echo "survey says... $errstr <br />\n"; } --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409

« previous php.internals (#38887) next »