내 응용 프로그램은 모든 요청을 인덱스 파일을 통해 라우팅합니다. 이 파일의 파일명은인덱스 파일에서 상수 정의
require_once $_SERVER['DOCUMENT_ROOT'] . "/app/config/config.php"
입니다.
이 구성 파일은 다른 곳에서 사용할 수 있도록 경로 상수를 정의하지만 작동하지 않는 것 같습니다. 예를 들어 config.php에서 나는
define('MODELS', $_SERVER['DOCUMENT_ROOT'] . "/app/models/");
입니다. 나는 다른 클래스를 포함하는 것을 시도하고 모델 파일 중 하나에서
같은
class classB {.....}
require_once MODELS . "classA.php"
의 config.php :
$root = $_SERVER['DOCUMENT_ROOT'] . "/";
define("APP",$root . "app/"); // app folder
define("CONFIG",$root . "app/config/"); // config folder
define("MODELS",$root . "app/models/"); // models folder
define("CONTROLLERS",$root . "app/controllers/"); // controllers folder
define("DB",$root . "app/db/"); // database connection folder
define("VIEWS",$root . "app/views/"); // views folder
define("FUNCTIONS",$root . "app/functions/"); // functions folder
define("LIBRARY",$root . "app/library/"); // library folder
define("PUBLIC",$root . "public/"); // public folder
의 index.php :
if(isset($_POST['submit']) && $_POST['submit'] == "Send")
{
require_once MODELS . "contact.php";
$contact = new contact();
}
은 '('모형 ', $ 값)를 정의' –
@u_mulder 죄송합니다, 즉 오타했다, 내 실제 코드는 따옴표 – joshpj1
어느 쪽이든 당신은 잘못된 상수의 이름 또는 설정 파일이 포함되지가 포함되어 있지 않습니다. –