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.<?phpif(!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');?>

You may or may not be right as the file name doesn't necessarily have to reflect a class name it contains (but it's usually considered a good practice). It isn't always a straightforward mapping (look at some PHP frameworks and autoload implementations).

In PHP 7.2, this code will trigger a "Deprecated: __autoload() is deprecated, use spl_autoload_register() instead in path\to\file.php on line *" error although the spl_autoload_register function really really exists.<?phpif(!function_exists('spl_autoload_register')){ function __autoload($class){// blah blah blah} }?>

<?phpif(!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; }//You have to give the class name and not the class's path for the first parameter in the class_exists() }spl_autoload_register('classAutoLoader');?>

Guys, this document ( i mean __autoload() ) not mentioned one special situation: if you both use __autoload() and spl_autoload_register(), the __autoload() function will never to be called. Although spl_autoload_register() documentation explained why, i decide to wrote this in case some one get confused and waste all day to figure out why.

It is highly recommended not to use the __autoload() function any more. Now the spl_autoload_register() function is what you should consider.<?phpif(!function_exists('classAutoLoader')){ function classAutoLoader($class){$class=strtolower($class);$classFile=$_SERVER['DOCUMENT_ROOT'].'/include/class/'.$class.'.class.php'; if(is_file($classFile)&&!class_exists($classFile)) include $classFile; } }spl_autoload_register('classAutoLoader');?>