从服务器上的任何地方包含文件 [英] include files from anywhere on the server
问题描述
我的网站在生产服务器上运行完美。我已经把它移动到另一台Web服务器。 (VPS)。
I have website running perfectly on production server. I have moved it to another web server. (VPS).
让我解释一下例子你:
目录结构:
Let me explain you with example: The directory structure:
includes/
header.php
business/
index.php
some other files...
index2.php
在我的previous版本,我用
In my previous version, I used
include_once(includes/header.php)
在index.php文件和index2.php。它运行良好。但在我的新服务器的设置它给我的错误就路径(明显)。
in index.php and index2.php. It runs fine. but in my new server setup it's giving me error regarding path (obvious).
ERROR:
include_once(includes/header.php): failed to open stream: No such file or directory
正因为如此:
Fatal error: Class 'EncryptionClass' not found
我觉得有,我需要做一些服务器配置。但是,我不知道怎么样?
请指导我。让我知道,如果你想了解更多信息。
I think there are some server configurations which I need to do. But, I don't know how? Please guide me. Let me know if you want more information.
推荐答案
如果使用PHP 5.3+尝试使用:
if using PHP 5.3+ Try using:
include_once(__DIR__.'/includes/header.php');
DIR 是一个神奇的常量,将返回完整目录,该文件在
DIR is a magic constant that will return the full directory that the file is in.
这篇关于从服务器上的任何地方包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!