note 113901 added to language.oop5.autoload
| From: | julianatjxmallettdotcom | Date: | Sun, 15 Dec 2013 23:41:15 +0000 |
| Subject: | note 113901 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197943@lists.php.net to get a copy of this message | ||
The tip to use spl_autoload_register() instead of __autoload() should be taken seriously. It seems
that __autoload() doesn't always get called when calling an unloaded class within a class, eg:
<?php
class MyClass {
public static function doStuff() {
//do some stuff
$a = MyOtherClass::otherStuff();
}
}
?>
Code similar to that gave me a 'class not found' error when using __autoload(). Using
spl_autoload_register() with the exact same autoload function fixed the problem.
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/113901
Del: integrated -- https://master.php.net/note/delete/113901/integrated
Del: useless -- https://master.php.net/note/delete/113901/useless
Del: bad code -- https://master.php.net/note/delete/113901/bad+code
Del: spam -- https://master.php.net/note/delete/113901/spam
Del: non-english -- https://master.php.net/note/delete/113901/non-english
Del: in docs -- https://master.php.net/note/delete/113901/in+docs
Del: other reasons-- https://master.php.net/note/delete/113901
Reject -- https://master.php.net/note/reject/113901
Search -- https://master.php.net/manage/user-notes.php