down00112 2010-07-04 12:29
浏览 45
已采纳

关于$ _REQUEST的问题

I am beginner in PHP and i read in manual that $_REQUEST is a associative array consisting of cookies, get and post arrays. I want to know which takes precedence in request array.

Say, suppose i have a variable user in $_POST as well as $_COOKIE, and if i use echo $_REQUEST['user'] then which would print. I tried it and i get the value set in $_POST. If i want to print value of $_COOKIE what should i use? I know $_COOKIE is there but still using $_REQUEST if i want to print it, then how should i do it?

Thanks in advance :)

  • 写回答

7条回答 默认 最新

  • douxianglu4370 2010-07-04 12:36
    关注

    From the PHP manual on $_REQUEST (php.net):

    Note: The variables in $_REQUEST are provided to the script via the GET, POST, and COOKIE input mechanisms and therefore could be modified by the remote user and cannot be trusted. The presence and order of variables listed in this array is defined according to the PHP variables_order configuration directive.

    In fact PHP uses the request_order config value, but falls back on variables_order if empty.

    A possible value for request or variables order might look like this: "GPC". This means that first all Get variables are associated, then the Post- and after that the Cookie variables are associated. The order is from left to right, already defined values are overwritten. Except from GET, POST and cookie values, PHP can also associate environment ("E") and server ("S") variables.

    You'll find the corresponding manual entries for the PHP config here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计