Php 在同一头函数中传递动作参数和变量参数

Php 在同一头函数中传递动作参数和变量参数,php,Php,我试图在同一个头函数中传递一个动作参数和一个变量参数 以下是我到目前为止编写的代码: header('Location: .?action=show_edit_form, word=$word'); 当我单独使用action参数时,它会转到下一页,但是当我尝试将变量与action参数一起传递时,它就不起作用了 请告知 URL中的查询字符串参数由&分隔,而不是由, PHP不会在用“引用的字符串中插入变量,您需要” 尽管大多数浏览器都会自动更正错误,位置头需要一个绝对URI 因此: 除非您确定您的

我试图在同一个头函数中传递一个动作参数和一个变量参数

以下是我到目前为止编写的代码:

header('Location: .?action=show_edit_form, word=$word');
当我单独使用action参数时,它会转到下一页,但是当我尝试将变量与action参数一起传递时,它就不起作用了

请告知

  • URL中的查询字符串参数由
    &
    分隔,而不是由
  • PHP不会在用
    引用的字符串中插入变量,您需要
  • 尽管大多数浏览器都会自动更正错误,
    位置
    头需要一个绝对URI
  • 因此:

    除非您确定您的变量中不会有特殊字符,否则您应该确保它的编码也正确,以便放入URL

    header("Location: http://example.com/foo.php?action=show_edit_form&word=" . urlencode($word));
    

    您对标题所做的只是将用户引用到另一个符合正常url的页面

    标题('位置:.?操作=显示\u编辑\u表单& 单词='。$word)

    在该页面上,您可以调用$_GET['word']。您可能还希望对值进行URL编码,以防止出现任何无效字符的不可预见的问题。请仔细查看header函数中的引号。

    例如

        Here i am trying to send the parameter id & message for the purpose of deleting record,So you  
        use the following code,
    
                 $Params="?action=delete&id=".$id."&mess=Deleted Sucessfully"; 
    
                 header("Location:company.php".$Params);
    
        So , in the next page you will get the parameter variable as,
    
                 $action=$_GET['action'];
    
                 $id=$_GET['id'];
    
                 $message=$_GET['mess'];
    
    
        Above is the format of passing multiple parameters.Hope it works...
    
    可能重复的
        Here i am trying to send the parameter id & message for the purpose of deleting record,So you  
        use the following code,
    
                 $Params="?action=delete&id=".$id."&mess=Deleted Sucessfully"; 
    
                 header("Location:company.php".$Params);
    
        So , in the next page you will get the parameter variable as,
    
                 $action=$_GET['action'];
    
                 $id=$_GET['id'];
    
                 $message=$_GET['mess'];
    
    
        Above is the format of passing multiple parameters.Hope it works...