note 117805 added to function.spl-autoload-register
| From: | eyeofmidas at gmail dot com | Date: | Wed, 12 Aug 2015 15:57:54 +0000 |
| Subject: | note 117805 added to function.spl-autoload-register | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203322@lists.php.net to get a copy of this message | ||
When switching from using __autoload() to using spl_autoload_register keep in mind that
deserialization of the session can trigger class lookups.
This works as expected:
<?php
session_start();
function __autoload($class) {
...
}
?>
This will result in "__PHP_Incomplete_Class_Name" errors when using classes deserialized
from the session.
<?php
session_start();
function customAutoloader($class) {
...
}
spl_autoload_register("customAutoloader");
?>
So you need to make sure the spl_autoload_register is done BEFORE session_start() is called.
CORRECT:
<?php
function customAutoloader($class) {
...
}
spl_autoload_register("customAutoloader");
session_start();
?>
----
Server IP: 72.52.91.14
Probable Submitter: 208.176.248.6
----
Manual Page -- http://php.net/manual/en/function.spl-autoload-register.php
Edit -- https://master.php.net/note/edit/117805
Del: integrated -- https://master.php.net/note/delete/117805/integrated
Del: useless -- https://master.php.net/note/delete/117805/useless
Del: bad code -- https://master.php.net/note/delete/117805/bad+code
Del: spam -- https://master.php.net/note/delete/117805/spam
Del: non-english -- https://master.php.net/note/delete/117805/non-english
Del: in docs -- https://master.php.net/note/delete/117805/in+docs
Del: other reasons-- https://master.php.net/note/delete/117805
Reject -- https://master.php.net/note/reject/117805
Search -- https://master.php.net/manage/user-notes.php