Php 如何使服务器识别全局文件名
假设文件和文件夹结构如下所示:Php 如何使服务器识别全局文件名,php,.htaccess,cpanel,fatal-error,Php,.htaccess,Cpanel,Fatal Error,假设文件和文件夹结构如下所示: public_html/interface/index.php public_html/includes/EliteScript.php public_html/interface/site/template.php 在第一个,我应该可以把这个 require_once(“includes/EliteScript.php”)并且它必须在服务器中查找includes/EliteScript.php,而不强制我将其更改为。/includes/EliteScript.p
require_once(“includes/EliteScript.php”)
并且它必须在服务器中查找includes/EliteScript.php
,而不强制我将其更改为。/includes/EliteScript.php
在public_html/interface/index.php
在第三个例子中,我应该能够把这个require_放一次(“includes/EliteScript.php”)
并且它必须在服务器中查找includes/EliteScript.php
,而不强制我在public\u html/interface/site/template.php中将其更改为。/../includes/EliteScript.php
我不知道该怎么解释,但希望你能理解我的问题。通过HTACCESS:
php_value include_path '/FULL_PATH/public_html'
通过PHP:
设置包含路径
set_include_path( '/FULL_PATH/public_html' );
或者将其添加到现有路径:
set_include_path(get_include_path() . PATH_SEPARATOR . '/FULL_PATH/public_html');
如果您不知道当前路径:
echo dirname( __FILE__ );
确保您的include路径在路径中有public\u html/
,这样做没有帮助。即使成功了,我也不想要。因为有很多页面,很难更改,当更改时会出现一个新的错误:(您的包含路径应该在一个位置更改,并且只能在一个位置更改,这是在您的文件中;显然,如果它给您一个错误,您没有正确地更改它