1
我正在为我的编辑器编写一个插件来支持Yii框架。 为了使这个插件工作,我需要从index.php
找到2个路径: 框架和配置路径。PHP:用最小的评价找出变量值
通常index.php
(这是Yii的入口点)看起来是这样的:
<?php
// change the following paths if necessary
$yii=dirname(__FILE__).'/../../../../../usr/share/php-libs/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
require_once($yii);
Yii::createWebApplication($config)->run();
基本上,我需要获得所需的文件和参数列表Yii::createWebApplication()
。
但是这里的代码可以是任何东西。字面上任何事情。那么是否有可能以某种方式运行这个文件达到Yii::createWebApplication()
,所以我可以找出应用程序目录的位置以及框架的位置?
要得到Yii :: app()我必须首先评估index.php文件。问题是我不想这样做,因为可以有任何东西。 ATM我有index.php的解决方案modifyng副本。它有效,但几乎不是一个好主意。 – Daniel 2012-08-10 16:57:42
您可以使用$ _SERVER [“DOCUMENT_ROOT”]和$ _SERVER ['PHP_SELF'](使用dirname())作为亲属路径。 DIRECTORY_SEPARATOR常量是一个很好的练习。 – 2012-08-10 17:43:47
我发现了一些东西。这个回声realpath('/ windows/system32');打印“C:\ WINDOWS \ System32”。 – 2012-08-10 17:48:45