我从数据库中提取一个页面名称,并将其放入this equal语句中:
// Redirect if not there
if ($db_client === $session_client) {
require("custom.php");
} else {
require("general.php");
}因此,在这里,$db_client是为自定义页面存储的客户端id,$session_client是会话中的id。如果匹配,则将用户带到custom.php,如果不匹配,则将用户带到general.php
出于某种原因,PHP会同时显示两个页面。general.php顶部的general.php和底部的custom.php
我在常规页面上使用这个:
// If not page (path) is stored in db than show general
if (empty($pagename)) {
require_once("general.php");
} else {
require_once("$pagename");
}有什么办法解决这个问题吗?
发布于 2011-04-29 00:56:37
问题可能出在不同的地方,而不是你想象的地方。特别是因为我们知道general.php可以包含在几个地方。
因此,您需要获取includes的实际顺序,以便对问题进行定位。
选项A。安装xdebug模块,您将能够获得每个调用的日志。
选项B更简单。在每个require运算符之前编写echo 'including-', <N>;。<N>是一个数字,每次使用都是唯一的。因此,您将能够知道是哪个操作符导致了不想要的include。
顺便说一句。require_once($pagename);不是比require_once("$pagename");更好吗?并确保$pagename变量的安全性不受相对路径攻击。
https://stackoverflow.com/questions/5760230
复制相似问题