我有一些require_once()
问题。require_once()问题
代码:
<?php
$serverName = $_SERVER['SERVER_NAME'];
if ($serverName != 'xxx.xxx.xxx.xxx') {
require_once($_SERVER['DOCUMENT_ROOT'] . "/config.php");
} else {
require_once($_SERVER['SERVER_NAME'] . "/config.php");
}
?>
错误/警告:
Warning: require_once() [function.require-once]: Unable to accesss xxx.xxx.xxx.xxx/config.php in /var/www/vhosts/site.com/httpdocs/inc/header.php on line 7
Warning: require_once(xxx.xxx.xxx.xxx/config.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/vhosts/site.com/httpdocs/inc/header.php on line 7
Fatal error: require_once() [function.require]: Failed opening required 'xxx.xxx.xxx.xxx/config.php' (include_path='.:') in /var/www/vhosts/site.com/httpdocs/inc/header.php on line 7
的config.php
文件被称为我的header.php
文件。一切都在本地很好,但一旦它在现场服务器上,我只是得到上面的错误。
不知道它是否重要,但我通过IP地址访问它,因为它是一个开发站点。
是的,config.php
文件确实存在于根目录中。
任何想法?
您刚才'回声$ _ SERVER ['SERVER_NAME]'看你到达那里呢? – 2012-02-28 01:11:08
由于安全原因您无法通过ip地址访问php文件 – 2012-02-28 01:13:18
@Michael - 是的,它返回IP地址 – 2012-02-28 01:18:13