1. <tfoot id='yRuNc'></tfoot>

      <small id='yRuNc'></small><noframes id='yRuNc'>

      <i id='yRuNc'><tr id='yRuNc'><dt id='yRuNc'><q id='yRuNc'><span id='yRuNc'><b id='yRuNc'><form id='yRuNc'><ins id='yRuNc'></ins><ul id='yRuNc'></ul><sub id='yRuNc'></sub></form><legend id='yRuNc'></legend><bdo id='yRuNc'><pre id='yRuNc'><center id='yRuNc'></center></pre></bdo></b><th id='yRuNc'></th></span></q></dt></tr></i><div id='yRuNc'><tfoot id='yRuNc'></tfoot><dl id='yRuNc'><fieldset id='yRuNc'></fieldset></dl></div>

        • <bdo id='yRuNc'></bdo><ul id='yRuNc'></ul>
      1. <legend id='yRuNc'><style id='yRuNc'><dir id='yRuNc'><q id='yRuNc'></q></dir></style></legend>

      2. PHP 中的 $_REQUEST

        时间:2023-10-12

            <tbody id='pi7Dr'></tbody>

          • <tfoot id='pi7Dr'></tfoot>
              <legend id='pi7Dr'><style id='pi7Dr'><dir id='pi7Dr'><q id='pi7Dr'></q></dir></style></legend>

                <bdo id='pi7Dr'></bdo><ul id='pi7Dr'></ul>
              • <i id='pi7Dr'><tr id='pi7Dr'><dt id='pi7Dr'><q id='pi7Dr'><span id='pi7Dr'><b id='pi7Dr'><form id='pi7Dr'><ins id='pi7Dr'></ins><ul id='pi7Dr'></ul><sub id='pi7Dr'></sub></form><legend id='pi7Dr'></legend><bdo id='pi7Dr'><pre id='pi7Dr'><center id='pi7Dr'></center></pre></bdo></b><th id='pi7Dr'></th></span></q></dt></tr></i><div id='pi7Dr'><tfoot id='pi7Dr'></tfoot><dl id='pi7Dr'><fieldset id='pi7Dr'></fieldset></dl></div>
                1. <small id='pi7Dr'></small><noframes id='pi7Dr'>

                  本文介绍了PHP 中的 $_REQUEST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有这个代码.

                  $message = "";
                  
                  if($_REQUEST['msg'] == "new"){
                      $message = "New User has been added successfully";
                  }else if($_REQUEST['msg'] == 'edit'){
                      $message = "User has been saved successfully";
                  }else if($_REQUEST['msg'] == 'update'){
                      $message = "User(s) has been Updated successfully";
                  }
                  

                  谁能在这里告诉我什么是['msg']并解释$_REQUEST的功能?

                  can any one please tell me here what is ['msg'] and please explain the functioning of $_REQUEST?

                  推荐答案

                  $_REQUEST 是一个超级全局数组.就像 $_GET、$_POST、$_COOKIE、$_SESSION 等.这意味着它可以以数字或关联方式存储列表信息.

                  $_REQUEST is a super global array. Just like $_GET, $_POST, $_COOKIE, $_SESSION etc. That means it can store a list information numerically or associatively.

                  例如:联想:$array = array(key->value, key->value);数字:$array = array([0]->value, [1]->value);

                  在 $_REQUEST 或 $_POST 或 $_GET 的情况下,这些数组将存储发送到 PHP 标头的编码数据.

                  In the case of $_REQUEST or $_POST or $_GET these arrays will store encoded data sent to the PHP header.

                  例如:$_REQUEST['key'] = value;

                  您有一个导航项:value//对于$_GET

                  you have a navigation item: <a href='?key=value'>value</a> //for $_GET

                  PHP 会将该键-> 值编码到 url 中,并将其保存到您正在使用的超级全局数组中.要访问它,请调用:echo $_REQUEST['key'];//返回'值'

                  PHP will encode that key->value into the url and save it to the super global array that you are using. To access it call: echo $_REQUEST['key']; //returns 'value'

                  到目前为止,您的情况 msg 尚未编码到浏览器中.它需要通过不同的方式(表单、href 等)传递.所以,

                  In your case msg is, so far, not encoded to the browser. It needs to be passed by different means(forms, href's etc.). So,

                   $_REQUEST['msg'] = 'new';
                   if(isset($_REQUEST['msg'])){       //use isset() to avoid an error
                      if($_REQUEST['msg'] == "new"){
                          $message = "New User has been added successfully";  
                      }else if($_REQUEST['msg'] == 'edit'){
                          $message = "User has been saved successfully";
                      }else if($_REQUEST['msg'] == 'update'){
                          $message = "User(s) has been Updated successfully";
                      }
                  }                           //returns $message = "New user..."
                  

                  $_REQUEST 不建议使用,因为它很难控制处理哪些信息.$_GET 请求在 url 中显示键-> 值对.您不希望显示的信息可能不应该显示在那里.使用 $_REQUEST 用户可以通过 url 发送该键-> 值对以查看需要传递哪些信息并以其他方式利用它(谷歌跨站点请求伪造).

                  $_REQUEST is not suggested because it makes it hard to control what information is processed. $_GET requests show the key->value pairs in the url. Information that you don't want as visible probably shouldn't be shown there. With $_REQUEST a user can send that key->value pair over the url to see what information needs to be passed and exploit that in other ways (google cross-site request forgeries).

                  TL;DR : $_REQUEST['msg'] -- 'msg' 是键->值对中的一个键('new'| 'edit' | 'update' 是值)

                  TL;DR : $_REQUEST['msg'] -- 'msg' is a key in a key->value pair ('new'| 'edit' | 'update' being the value)

                  $_REQUEST 是一个超全局数组,用于保存用户可以在网站其他部分的任何范围内使用的值.

                  $_REQUEST is a superglobal array that saves values that can be used by the user in any scope in other parts of the website.

                  这篇关于PHP 中的 $_REQUEST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:PHP $_REQUEST 作为数组 下一篇:Symfony - 找不到表单请求的 url

                  相关文章

                    <bdo id='1yU4i'></bdo><ul id='1yU4i'></ul>
                  1. <legend id='1yU4i'><style id='1yU4i'><dir id='1yU4i'><q id='1yU4i'></q></dir></style></legend>

                  2. <i id='1yU4i'><tr id='1yU4i'><dt id='1yU4i'><q id='1yU4i'><span id='1yU4i'><b id='1yU4i'><form id='1yU4i'><ins id='1yU4i'></ins><ul id='1yU4i'></ul><sub id='1yU4i'></sub></form><legend id='1yU4i'></legend><bdo id='1yU4i'><pre id='1yU4i'><center id='1yU4i'></center></pre></bdo></b><th id='1yU4i'></th></span></q></dt></tr></i><div id='1yU4i'><tfoot id='1yU4i'></tfoot><dl id='1yU4i'><fieldset id='1yU4i'></fieldset></dl></div>
                  3. <small id='1yU4i'></small><noframes id='1yU4i'>

                    <tfoot id='1yU4i'></tfoot>