如何让服务器识别全局文件名
How to make server recognize global filenames
假设文件和文件夹结构如下:
- public_html/interface/index.php
- public_html/includes/EliteScript.php
- public_html/interface/site/template.php
在第一个,我应该可以把这个
require_once("includes/EliteScript.php");
并且它必须在服务器中查找 includes/EliteScript.php
,而不是强迫我在 public_html/interface/index.php
中将其更改为 ../includes/EliteScript.php
在第 3 个中,我应该可以放置这个 require_once("includes/EliteScript.php");
并且它必须在服务器中查找 includes/EliteScript.php
,而不是强迫我在 [= 中将其更改为 ../../../includes/EliteScript.php
17=]
我不知道怎么解释,但希望你能明白我在问什么。
超过 HTACCESS:
php_value include_path '/FULL_PATH/public_html'
超过 PHP:
设置你的include_path
set_include_path( '/FULL_PATH/public_html' );
或将其添加到您现有的路径中:
set_include_path(get_include_path() . PATH_SEPARATOR . '/FULL_PATH/public_html');
如果您不知道当前路径:
echo dirname( __FILE__ );
假设文件和文件夹结构如下:
- public_html/interface/index.php
- public_html/includes/EliteScript.php
- public_html/interface/site/template.php
在第一个,我应该可以把这个
require_once("includes/EliteScript.php");
并且它必须在服务器中查找 includes/EliteScript.php
,而不是强迫我在 public_html/interface/index.php
../includes/EliteScript.php
在第 3 个中,我应该可以放置这个 require_once("includes/EliteScript.php");
并且它必须在服务器中查找 includes/EliteScript.php
,而不是强迫我在 [= 中将其更改为 ../../../includes/EliteScript.php
17=]
我不知道怎么解释,但希望你能明白我在问什么。
超过 HTACCESS:
php_value include_path '/FULL_PATH/public_html'
超过 PHP:
设置你的include_path
set_include_path( '/FULL_PATH/public_html' );
或将其添加到您现有的路径中:
set_include_path(get_include_path() . PATH_SEPARATOR . '/FULL_PATH/public_html');
如果您不知道当前路径:
echo dirname( __FILE__ );