我遇到了使用 php 标头函数将变量作为 id 传递的问题。我在这里给出了我的代码。假设变量是整数值为 2 的 $id。我想将页面重定向到 example.php?id=2 我该怎么做?
这是行不通的。需要你的帮助。提前谢谢。
这应该可以正常工作:header('Location: example.php?id='.$id);
.在调用header();
之前,请确保没有输出,甚至没有空格
你可以使用 php 标头函数
<?php
header('Location: example.php?id='.$id);
exit();
?>
你可以像这样使用标头函数。
header("location:example.php?id=".$id);