note 113847 added to function.autoload
| From: | Anonymous | Date: | Sun, 08 Dec 2013 07:11:52 +0000 |
| Subject: | note 113847 added to function.autoload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-197838@lists.php.net to get a copy of this message | ||
It is highly recommended not to use the __autoload() function any more. Now the
spl_autoload_register() function is what you should consider.Sorry for the mistake in line 6 of my
previous note. And below is the corrected PHP code.
<?php
if(!function_exists('classAutoLoader')){
function classAutoLoader($class){
$class=strtolower($class);
$classFile=$_SERVER['DOCUMENT_ROOT'].'/include/class/'.$class.'.class.php';
if(is_file($classFile)&&!class_exists($class)) include $classFile;
}
}
spl_autoload_register('classAutoLoader');
?>
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/function.autoload.php
Edit -- https://master.php.net/note/edit/113847
Del: integrated -- https://master.php.net/note/delete/113847/integrated
Del: useless -- https://master.php.net/note/delete/113847/useless
Del: bad code -- https://master.php.net/note/delete/113847/bad+code
Del: spam -- https://master.php.net/note/delete/113847/spam
Del: non-english -- https://master.php.net/note/delete/113847/non-english
Del: in docs -- https://master.php.net/note/delete/113847/in+docs
Del: other reasons-- https://master.php.net/note/delete/113847
Reject -- https://master.php.net/note/reject/113847
Search -- https://master.php.net/manage/user-notes.php