I did test both of codes to autoload Classes to page,But not work for me!
What's wrong ?
spl_autoload_extensions('.php, .class.php');
spl_autoload_register(function ($name){
if('inc/'."{$name}".'.class.php'){
require('inc/'."{$name}".'.class.php');
}
});
AND :
class FW{
public static function autoload($class){
$class = strtolower($class);
$fpath = realpath(dirname(__FILE__)).'/inc/'."{$class}". '.class.php';
if(is_readable($fpath)){
require_once($fpath);
}
}
}
spl_autoload_register('FW::autoload');
As my question have not answer I reply answer and hope it will be useful.
I add the code to Config.php and edit classes name style form whatever.class.php
to class.whatever.php
and it's work for me.
// Classes Autoloader
spl_autoload_extensions('.php, .class.php');
spl_autoload_register(function ($name){
if(is_readable(realpath(dirname(__FILE__)).'/inc/class.'."{$name}".'.php')){
require(realpath(dirname(__FILE__)).'/inc/class.'."{$name}".'.php');
}
});