如何使用PHP头函数将URL传递给URL?
问题描述:
我面临的问题是传递变量作为身份证与PHP头函数。我在这里给我的代码。假设变量是$ id,它具有整数值2.我想将页面重定向到example.php?id = 2我该怎么做?如何使用PHP头函数将URL传递给URL?
这是行不通的。需要你的青睐。提前致谢。
答
这应该工作得很好:header('Location: example.php?id='.$id);
。在调用header();
答
之前,请确保没有输出,甚至没有空格,您可以使用这样的标题功能。
header("location:example.php?id=".$id);