나는 나의 config.php를을 포함하여 각 페이지에 내 헤더를 삽입하려면 다음을 사용하고 있습니다 :__DIR__을 올바르게 사용 했습니까?
Warning: require_once(/opt/lampp/htdocs/templates/admin/config.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/templates/admin/listArticles.php on line 1
그러나
<?php require_once __DIR__."/config.php"; require_once SITE_ROOT."/templates/include/header.php" ?>
, 그래서, 나는 다음과 같은 오류를 수신 할 때 referance에 들어,이 config.php를 보이는 것입니다 같은 :
<?php
ini_set("display_errors", true);
date_default_timezone_set("Australia/Sydney"); // http://www.php.net/manual/en/timezones.php
define("DB_DSN", "mysql:host=localhost;dbname=cms");
define("DB_USERNAME", "username");
define("DB_PASSWORD", "password");
define("CLASS_PATH", "classes");
define("TEMPLATE_PATH", "templates");
define("HOMEPAGE_NUM_ARTICLES", 5);
define("ADMIN_USERNAME", "admin");
define("ADMIN_PASSWORD", "mypass");
define('SITE_ROOT', __DIR__);
require(CLASS_PATH . "/Article.php");
function handleException($exception) {
echo "Sorry, a problem occurred. Please try later.";
error_log($exception->getMessage());
}
set_exception_handler('handleException');
?>
SITE_ROOT가 정의되지 않았다는 오류 메시지가 이전에 수신되었다는 것을 언급 할 가치가 있습니다. 그러나 이후 befoer /config.php 디렉토리를 포함시켜이 문제를 해결했습니다.
사이트의 다른 곳에서도 require_once__DIR__ ..을 사용하려고했는데 정상적으로 작동합니다.
오류의 원인은 무엇입니까? 귀하의 오류 메시지
Warning: require_once(/opt/lampp/htdocs/templates/admin/config.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/templates/admin/listArticles.php on line 1
보면
이 라인을 정의하는 곳 define ('SITE_ROOT', __DIR__); ? in which file – samehanwar
그 줄은 위에서 언급 한 config.php의 일부입니다. config.php의 모든 내용을 포함하도록 게시물을 편집합니다. –