如何在php中使用通过header()传递的变量 [英] how to use variables passed through header() in php
本文介绍了如何在php中使用通过header()传递的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 header()
将var user
从一页传递给另一页,如下所示:
I'm using header()
to pass var user
from one page to another as:
header( "Location: temp.php? user = $user" );
该变量被传递,并显示在另一页的url上.
the variable is getting passed and is shown on the url of another page.
但是我不知道如何在该页面中使用这些var user
.请帮忙.
But i dont know how to use these var user
in that page. Please help.
推荐答案
如果其他页面"在PHP中,则只需要:
if the 'other page' is in PHP, you only need to:
$user=$_GET['user'];
如果不确定是否会收到用户",并且希望避免出现错误消息,则应该执行以下操作:
If you are not sure if you will receive 'user' and want to avoid error messages you should do:
if(isset($_GET['user'])){
$user=$_GET['user'];
}else{
//user was not passed, so print a error or just exit(0);
}
这篇关于如何在php中使用通过header()传递的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文