php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #53058 __autoload example #1
Submitted: 2010-10-14 02:15 UTC Modified: 2010-10-19 06:07 UTC
From: jay at grooveshark dot com Assigned: kalle
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID:
 [2010-10-14 02:15 UTC] jay at grooveshark dot com
Description:
------------
This was rejected as a note from the documentation with no explanation, I assume because it was considered a documentation bug:

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



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-19 06:06 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304492
Log: Fixed bug #53058 (__autoload example #1)
 [2010-10-19 06:06 UTC] kalle@php.net
-Assigned To: +Assigned To: kalle
 [2010-10-19 06:07 UTC] kalle@php.net
-Status: Assigned +Status: Closed
 [2010-10-19 06:07 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 13:01:59 2014 UTC