【发布时间】:2009-02-01 20:23:07
【问题描述】:
引导您的 PHP 应用程序是一个好习惯吗? 我找到了两种方法来引导我的 PHP 应用程序。需要一些更好的建议。
首先。
为文件夹结构定义一个常量
$controllerPath = 'controller';
define('CONTROLLER', str_replace('\\', '/', realpath($controllerPath)).'/');
//usage
require_once CONTROLLER . 'somecontroller.php';
第二
使用 ini_set 设置应用程序根目录的包含路径
$rootPath = $_SERVER['DOCUMENT_ROOT'];
$includePath = ini_get('include_path');
ini_set('include_path', '.'.PATH_SEPARATOR.$rootPath.PATH_SEPARATOR.$includePath);
//usage
require_once 'controller/somecontroller.php';
请告诉我哪种方法更好。
如果是高负载应用程序,哪种方法是最好的方法??
【问题讨论】:
标签: php bootstrapping