私は私の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" ?>
、私はそう、私は次のエラーが表示されないとき
<?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のすべての内容を追加します。 –