2013-08-05 2 views
0

나는 몇 오토로더를 등록하기 위해 노력하고있어 및 I는 HTTP를 얻을 :이 오류 로그의 끝에 약간의 스택 트레이스 부분이었다, 그러나이 보여 온 오토로더에 어떤 문제가 있습니까? (500) 내 오류 로그에 다음 말한다

[05-Aug-2013 04:32:38 UTC] PHP Fatal error: Uncaught exception 'LogicException' with message 'Function 'Autoloader::config' not callable (non-static method Autoloader::config() should not be called statically)' in /home2/canforce/public_html/index.php:5

거대한 편지를 써서 꺼내서 중요하다고 생각하지 않았습니다.


index.php를

include("config/autoloader.php"); 
spl_autoload_register('Autoloader::config'); 
spl_autoload_register('Autoloader::controller'); 
spl_autoload_register('Autoloader::service'); 



설정/자동 로더 :

나는 나의 오토로더 내가 읽은 내용에 따라 작동해야하지만 어떤 이유가 여기에 코드입니다하지 않습니다 생각 당신은 Autoloader 클래스의 인스턴스를 생성하고 그것을 전달해야

class Autoloader { 
function config($class) { 
    $file = 'config/' . $class . '.php'; 
    if(file_exists($file)) { 
     require_once $file; 
    } 
} 
function controller($class) { 
    $file = 'presentation/controllers/' . $class . '.php'; 
    if(file_exists($file)) { 
     require_once $file; 
    } 
} 
function service($class) { 
    $file = 'model/services/' . $class . '.php'; 
    if(file_exists($file)) { 
     require_once $file; 
    } 
} 
} 
+1

오류 메시지는 문제를 해결하는 데 필요한 모든 것을 알려줍니다. 비 정적 함수를 정적으로 호출합니다. – Maerlyn

+0

@Maerlyn 내가 조금 더 신중하게 읽었다면 당신 말이 맞습니다. 모든 txt와 큰 단어는 코딩의 긴 하루를 보낸 후에 약간의 압도를가했습니다./그것은 의미가 있으며 작동하지만 이상한 문서는 내가 읽은 문서 중 아무 것도 인스턴스화해야한다는 것을 보여주었습니다. – Aaron

답변

0

에 .php 레지스터 기능으로.

include("config/autoloader.php"); 
$autoloader = new Autoloader(); 
spl_autoload_register(array($autoloader, 'loader')); 
관련 문제