PHP函数与第二个参数/参数混淆

PHP函数与第二个参数/参数混淆,php,function,arguments,Php,Function,Arguments,在所有脚本结束时,我运行一个函数closeConnection,即: closeConnection("success"); function closeConnection($note) { if ($note === "success") { $append = "?success"; } if ($note === "blank") { $append = "?blank"; } mysql_close(); header("Location: index

在所有脚本结束时,我运行一个函数
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?已更新


实际结果:重定向到
.php?blank

根据我的经验,您正在调用
closeConnection(“更新”)关闭连接之前的某个地方(“更新”、“查看”)但你忘了删除它或其他东西


确保您没有忘记以前的命令,并且您实际上保存了正确的文件。

是您的实际结果“.php?blank”还是“.php?”如果没有以任何方式进行设置,您为什么希望看到更新的
?如果您通过
success
,则唯一的可能性是
?success
<代码>?如果您通过
blank
则为空,或者如果您通过其他任何内容(例如
查看
$header=$header,则为空???
$header=$header=>不需要这样做;)对不起,从我的代码中复制了错误的
if
语句(有很多)。正确的一个应该在那里了。并且,
$header=$header
存在,因为我不确定是否需要“拉入”函数的参数。。。这些对我来说都是新的。实际结果是
.php?空白