我在我的項目中使用了未定義的常量錯誤。這裏是設置在我的項目中使用PHP定義的常量錯誤PDO
常數是;
define('VIEW_ROOT_ADMIN', '/views/admin');
並從稱爲文件是
<?php
$mode = file_get_contents('../app/mode.php');
require '../app/' . $mode . '.php';
require VIEW_ROOT_ADMIN . '/index.php';
這是錯誤發生時;
Notice: Use of undefined constant VIEW_ROOT_ADMIN - assumed 'VIEW_ROOT_ADMIN'
的這一奇怪的是,在這裏工作正常,在這個文件結構如下
define('VIEW_ROOT', '/views');
<?php
$mode = file_get_contents('app/mode.php');
require 'app/' . $mode . '.php';
require VIEW_ROOT . '/index.php';
任何幫助將是不錯的:-)
這是文件結構
ROOT----
|--admin
|--index.php
|--app
|--development.php //Here are the contants define('VIEW_ROOT', '/views'); and define('VIEW_ROOT_ADMIN', '/views/admin');
|--mode.php
|--production.php
|--views
|--admin
|--index.php
|--index.php
index.php
'$ mode = file_get_contents('../ app/mode.php'); 需要'../app/'。 $模式。 '.php';'沒有任何意義。 –
這只是模式的開發或生產環境 – John
是啊......無論如何。您提出了很多問題,但尚未接受任何答案。這個網站是雙向的。如果你期望得到幫助,你應該通過接受他們的回答來獎勵那些幫助你的人。閱讀[接受答案如何工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)並開始回饋社區。另外,你會得到重要的分數,那些如此優雅地給予他們空閒時間來幫助你的人。 –