奇怪的问题,在Windows上的PHP ...我的应用程序加载,加载一个设置文件,寄存器自动加载一个“核心”文件,不初始化等为核心文件的顶部我有include_once(“config.php文件“);这适用于当前目录中的任何内容,如果我从一个单独的目录中包含核心文件,尽管它只是默默地忽略配置文件的包含......有没有人看到过这个?require_once忽略
/webroot/core.php
<?php
require_once "config.php";
//register autoloads
//do some initialization... standard stuff
?>
/webroot/config.php
<?php
define("WEB_ROOT","/webroot");
define("DB_USER","root");
// ... more stuff...
?>
/webroot/admin/index.php
<?php
require_once("../dbconnect.php");
echo WEB_ROOT;
// print string literal WEB_ROOT rather than value in config.php
?>
我的理解是,文件操作是相对于发出请求的文件的目录而言的,不应该在require_once(“config.php”)中选择文件re lative到core.php?这段代码的工作原理与我在Mac或Linux上所期望的一样,但在Windows上完全没有,(如果我改变require的使用完整路径或../,它会起作用)
真正的疯狂是require_once(“config.php”)不会抛出任何错误,但是里面的代码都不会被执行!
已经有人注意到的index.php是装载dbconnect.php而不是config.php或core.php?您还需要显示dbconnect.php的内容以及... – 2013-10-03 07:16:32