duannao3819 2012-11-07 09:01
浏览 166

如何在php中使用通过header()传递的变量[关闭]

I'm using header() to pass var user from one page to another as:

header( "Location: temp.php? user = $user" );

the variable is getting passed and is shown on the url of another page.

But i dont know how to use these var user in that page. Please help.

  • 写回答

3条回答 默认 最新

  • dqpc1845 2012-11-07 09:03
    关注

    if the 'other page' is in PHP, you only need to:

    $user=$_GET['user'];
    

    EDIT: 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);
    }
    
    评论

报告相同问题?