1
PHP 5.3 네임 스페이스 클래스를 자동로드하려고합니다.PHP 5.3 클래스를 자동로드하는 방법은 무엇입니까?
/JM
Auth.php
User.php
Db/Entity.php
/...
나는
namespace KM;
class Autoloader {
public static function registerAutolaod() {
ini_set('include_path', dirname(__FILE__) . PATH_SEPARATOR . ini_get('include_path'));
spl_autoload_register(function ($classname) {
$file = preg_replace('/\\\/', DIRECTORY_SEPARATOR, $classname) . '.php';
echo $file . '<br />';
include ($file);
});
}
}
문제가 가끔 어떻게이 문제를 해결할 수 KM\User
User
로 클래스 명을 얻을 때로는나요?