note 100395 rejected from language.oop5.autoload by danbrown

From: Date: Wed, 13 Oct 2010 22:15:53 +0000
Subject: note 100395 rejected from language.oop5.autoload by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173201@lists.php.net to get a copy of this message
Note Submitter: Jay at grooveshark dot com ---- Example #1 would be better as: function __autoload($class_name) { include $class_name . '.php'; } Making it an include rather than a require makes it a warning if the file fails to load rather than a fatal, and PHP will instead fatal where the class is being used. The net result is that the error logs will report the actual source of the error rather than pointing to the autoloader. Removing the _once just makes it slightly more efficient since _once is not necessary inside of __autoload because it will only try to load a class if it's not already defined. More info: http://p3n.us/q7

« previous php.notes (#173201) next »