Php 设置使用显式相对路径的包含路径
我知道这句话:Php 设置使用显式相对路径的包含路径,php,Php,我知道这句话: set_include_path(get_include_path() . PATH_SEPARATOR . '/my/other/path'); 将'/my/other/path'添加到需要的目录列表中,包含(和其他)函数查找文件 但此选项仅对路径开头未指定/或./的路径有效。例如: // I would include /my/other/path/Zend.php require('Zend.php'); // it works require('./Zend.php'
set_include_path(get_include_path() . PATH_SEPARATOR . '/my/other/path');
将'/my/other/path'
添加到需要
的目录列表中,包含
(和其他)函数查找文件
但此选项仅对路径开头未指定/
或./
的路径有效。例如:
// I would include /my/other/path/Zend.php
require('Zend.php'); // it works
require('./Zend.php'); // it does not works
// or if I would include /my/other/Zend.php
require('../Zend.php'); // still does not works
然而我正在寻找一种方法来实现它
注:这适用于偏心项目。在这种情况下,我无法使用include和require函数修改文件。IMO,要实现这一点,唯一可以做的事情是:将当前工作目录设置为适合相对路由的目录。什么不可以?您只需始终使用fill path
require(ZEND_path./ZEND.php')
古怪的
看起来像个大字。。我没有读那部分:)