note 104282 added to language.oop5.autoload
| From: | bimal at sanjaal dot com | Date: | Sun, 05 Jun 2011 18:58:53 +0000 |
| Subject: | note 104282 added to language.oop5.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180284@lists.php.net to get a copy of this message | ||
When multiple scripts try to use __autoload(), there is a collision.
I experienced it while upgrading the Smarty and my own autoload function.
So, the better way is to avoid __autoload() and use spl_register_autoload() instead. If you have
written this already, just rename your function to something like __autoload_my_classes, and in the
next, call spl_autoload_register as:
<?php
function __autoload_my_classes($classname)
{
# ... your logic to include classes here
}
spl_autoload_register('__autoload_my_classes');
?>
You can assign multiple functions to spl_autoload_register() by calling it repeatedly with different
function names. Be sure to limit your every function to include a CLASS file.
----
Server IP: 69.147.83.197
Probable Submitter: 110.34.0.242 (proxied: 116.66.193.69)
----
Manual Page -- http://www.php.net/manual/en/language.oop5.autoload.php
Edit -- https://master.php.net/note/edit/104282
Del: integrated -- https://master.php.net/note/delete/104282/integrated
Del: useless -- https://master.php.net/note/delete/104282/useless
Del: bad code -- https://master.php.net/note/delete/104282/bad+code
Del: spam -- https://master.php.net/note/delete/104282/spam
Del: non-english -- https://master.php.net/note/delete/104282/non-english
Del: in docs -- https://master.php.net/note/delete/104282/in+docs
Del: other reasons-- https://master.php.net/note/delete/104282
Reject -- https://master.php.net/note/reject/104282
Search -- https://master.php.net/manage/user-notes.php