我正在尝试推出自己的项目,但是遇到了一个错误,我发现这个错误有点古怪,而且我的 IDE 和 xDebug 并没有为像我这样的新手提供很多选择。
下面的代码有几个问题,但是使用未定义的常量包含 - 假设“包含”让我很烦,我不知道出了什么问题。
<?php
//Debug Error Reporting Configuration
error_reporting(E_ALL);
/*
Do Not Change any of these items unless
you know what they do and you realy
have to change them
*/
//Global Function to return includes path
function includes($path, $location){
return $_SERVER['DOCUMENT_ROOT']. "/" .$path. "/" .$location;
}
//Global Function to return single location path
function location($path){
return $_SERVER['DOCUMENT_ROOT']. "/" .$path;
}
//Global Functions Include
require(includes(includes, 'functions.php'));
//Messaging Array
$messages=array();
//Database Configuration & Connection
$dbhost="localhost";
$dbuser="root";
$dbpass="SaltWater";
$dbname="platform";
connectToDB();
//Session Variable Registration
session_register("f_name");
session_register("user_id");
session_register("company_id");
//Smarty Template Engine Configuration
define('SMARTY_DIR', includes(includes, smarty));
require(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
$smarty->setTemplateDir(location(templates));
$smarty->setCompileDir(location(cache));
$smarty->setCacheDir(location(cache));
function errorsys($type, $detail){
$smarty->assign('type',$type);
$smarty->assign('detail',$detail);
$smarty->display('error.tpl');
}
?>
编辑:有没有一种我还没有发现的更简单的方法来做一个聪明的方法来做我的包含,而不需要通常在文件夹中向下钻取,以防它被部署到不同的服务器上?