douxian4376 2014-04-01 18:51
浏览 86
已采纳

PHP中的$ _POST,$ _GET,$ _SESSION和$ _COOKIES是从页面到页面传递变量的唯一方法吗?

The question speaks for itself, but is there any other method?

Could you kindly share them even if those are the best practices?

  • 写回答

6条回答 默认 最新

  • dongzhu6900 2014-04-01 18:54
    关注

    Those are the most obvious ways to input information into a page. It is possible to parse the input from the url in another way than $_GET, but why would you.

    Also, you can use other methods. For instance, you could save information in a file or database and read it in the next page, although you might still need some information in a cookie or the url to identify which information to read (session id).

    So, while strictly the answer to your question is 'no', I want to say 'yes', these are the methods you will commonly use.

    If it's strictly about those global variables, then you've got the $_REQUEST variable, which basically collects all values from $_GET, $_POST and $_COOKIE together. And $_FILES gives information about uploaded files, which are automatically stored in a temporary location, although in essence, those files are also posted to the page. So, these globals help you making things easy regarding the most common methods to communicate with a script.

    All these are for input, by the way. You cannot send information back, or to the next page, by modifying these $_SUPERGLOBALS.

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

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题