Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将外部php文件包含到zend framwork中_Php - Fatal编程技术网

将外部php文件包含到zend framwork中

将外部php文件包含到zend framwork中,php,Php,我想将外部php文件包括到我的zend项目中,但我无法做到这一点。我将外部文件放在zend项目的public文件夹中。下面是我正在尝试的 require_once (Zend_Controller_Front::getInstance()->getBaseUrl().'/myfile/include/phpfile.php'); 但是我犯了以下错误 ( ! ) Warning: require_once(/myproject/public/myfile/include/phpfile.p

我想将外部php文件包括到我的zend项目中,但我无法做到这一点。我将外部文件放在zend项目的public文件夹中。下面是我正在尝试的

require_once (Zend_Controller_Front::getInstance()->getBaseUrl().'/myfile/include/phpfile.php');
但是我犯了以下错误

( ! ) Warning: require_once(/myproject/public/myfile/include/phpfile.php): failed to open stream: No such file or directory
getBaseUrl()
用于计算要在路由匹配中使用的URL,而不是计算服务器路径:

假设您的应用程序文件夹与公用文件夹处于同一级别,则以下内容可用于获取phpfile.php的路径:

$path = realpath(APPLICATION_PATH . '/../public/myfile/include/phpfile.php')
这假设您有一个标准index.php设置,并带有应用程序路径常量

然后,您可以要求$path变量:

require_once($path);
但是,您还应该考虑在任何公共路径上使用require是否明智,出于安全原因,php文件可能会更好地放置在/public路径之外