我有一些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
文件确实存在于根目录中。
有任何想法吗?