繁体   English   中英

如何使用PHP标头函数通过URL传递ID?

[英]How can I pass id with URL using PHP header function?

我面临的问题是通过PHP标头函数将变量作为id传递。 我在这里给出了我的代码。 假设变量是$ id,它的整数值为2。我想将页面重定向到example.php?id = 2,该怎么做?

这是行不通的。 需要你的帮助。 提前致谢。

这应该可以正常工作: header('Location: example.php?id='.$id); 在调用header();之前,请确保没有输出,甚至没有空格header();

您可以像这样使用标题函数。

header("location:example.php?id=".$id);

您可以使用php标头功能

<?php
   header('Location: example.php?id='.$id);
   exit();
?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM