일부 파일이 필요하고 경로를 올바르게 가져 오는 데 문제가 있습니다. 파일을 포함 할 때 경로가 잘못되었습니다.
그래서 나는이 같은 config.php를 일부 상수를 정의 :
여기에 내 현재 폴더 및 파일 구조입니다
는define('APP_ROOT', __DIR__);
define('VIEW_ROOT', APP_ROOT . '/views');
define('TEMPLATE_ROOT', APP_ROOT . '/views/templates');
define('BASE_URL', 'http://localhost:8080/site');
start.php는 데이터베이스 연결을 포함합니다. 그래서 나중에 난 단지 다른 장소에서 헤더 파일을 필요로 할
require APP_ROOT . '/config.php';
require APP_ROOT . '/start.php';
그래서 나는 admin_header.php에이 두 파일을 추가하려면 다음 admin_header.php으로
나는이 두 파일을 추가했습니다.
나는 관리자에서 아래의 파일을 필요할 때/index.php에
require TEMPLATE_ROOT . '/admin_header.php';
require VIEW_ROOT . '/admin/index.php';
require TEMPLATE_ROOT . '/admin_footer.php';
나는 다음과 같은 오류를 얻을 : 당신이 있기 때문에
이Notice: Use of undefined constant TEMPLATE_ROOT - assumed 'TEMPLATE_ROOT' in F:\wamp64\www\site\admin\index.php on line 2
Warning: require(TEMPLATE_ROOT/admin_header.php): failed to open stream: No such file or directory in F:\wamp64\www\site\admin\index.php on line 2
Fatal error: require(): Failed opening required 'TEMPLATE_ROOT/admin_header.php' (include_path='.;C:\php\pear') in F:\wamp64\www\site\admin\index.php on line 2
당신이'index.php' 전에'config.php'를 호출하고 있습니까? (또는 index.php 포함) –
** 치킨 & 에그 파라독스 ** :'APP_ROOT가 필요합니다. '/config.php';'하지만'config.php'에서는 처음으로'APP_ROOT' 상수를 정의합니다. 큰 논리 문제. 'admin/index.php'는'require '와 같이'config.php'를 먼저 포함해야합니다 .. ../app/config.php'; ' – JustOnUnderMillions
@Antonis : VIEW_ROOT가 필요합니다. '/admin/index.php'; 메인 admin/index.php보기입니다 – PapT