【发布时间】:2014-06-09 08:55:01
【问题描述】:
在我所有脚本的最后,我运行了一个函数closeConnection,即:
closeConnection("success");
function closeConnection($note) {
if ($note === "success") { $append = "?success"; }
if ($note === "blank") { $append = "?blank"; }
mysql_close();
header("Location: index.php" . $append . "");
exit();
}
这运行顺利。
但是,我现在希望我的 closeConnection() 函数接受两个参数,以便我可以选择不同的页面进行重定向。这是第二次的样子:
closeConnection("updated", "view");
function closeConnection($note, $header) {
$header = $header; // Not sure if needed, doesn't work with or without.
if ($note === "updated") { $append = "?updated"; }
if ($note === "blank") { $append = "?blank"; }
mysql_close();
header("Location: " . $header . ".php" . $append . "");
exit();
}
想要的结果:重定向到view.php?updated
实际结果:重定向到.php?blank
【问题讨论】:
-
你的实际结果是“.php?blank”还是“.php?”
-
如果没有以任何方式设置
?updated,为什么您会期望看到它?如果您通过success,唯一的可能性是?success;?blank如果你通过blank或者如果你通过其他任何东西(例如view) -
$header = $header;??? -
$header = $header;=> 不需要这样做 ;) -
对不起,从我的代码中复制了错误的
if语句(有很多)。正确的应该现在在那里。$header = $header在那里是因为我不确定是否需要“拉入”函数的参数......这些对我来说都是新的。实际结果是.php?blank