是否有任何真正的原因POST区分和处理输入数据时,得到什么? [英] Is there any real reason to differentiate between POST and GET when handling incoming data?

查看:134
本文介绍了是否有任何真正的原因POST区分和处理输入数据时,得到什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我一直在使用取GET和POST数据,让我用一个单一的getter函数访问它的包装PHP类。经过多年的开发Web应用程序的我从来没有一个很好的理由去关心传入的变种是否是从POST来或GET。不仅如此,但我真是厌倦了不必检查两个数组的单变量的。

Lately I've been using a wrapper PHP class that fetches GET and POST data and lets me access it using a single getter function. After years of developing web applications I've never had a single good reason to care whether an incoming var was coming from POST or GET. Not only that but I got really sick and tired of having to check both arrays for a single variable.

今天我注意到,codeigniter有POST数据的一个getter函数,一个用于GET。是否有任何一点呢?已经有人在这里曾经有一个理由去关心他的数据是从哪里来的?

Today I noticed that codeigniter has one getter function for POST data and one for GET. Is there any point to this? Has anyone here ever had a reason to care where his data is coming from?

一对夫妇的澄清:我不是问POST或之间的差异GET或哪一个我应该使用将数据发送到一个页面。我问我是否应该关心,如果数据是通过GET或POST抵达到我的网页。

A couple of clarifications: I'm not asking about the differences between POST or GET or which one I should use to send data to a page. I'm asking about whether I should care if data is arriving to my page via GET or POST.

推荐答案

HTTP标准定义了不同语义GET / POST操作(http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html 9.1秒0.1)

The HTTP standard defines different semantics for get/post operations (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html Sec 9.1.1)

在特定的使用您将数据从GET请求来可以做信息检索,但你不应该做任何事情,它涉及到状态改变的一些概念。这其中的一个原因是,用户代理可以prefetch页面(和做GET请求),而用户实际点击一个链接。 (一致认为是Web浏览器中notvery常见,但我听说过的邮件客户端这样做的)

In particular you can do information retrieval using data coming from a get request, but you shouldn't do anything which involves some notion of state change. One reason for this is that the user agent may prefetch pages (and doing get requests) without the user actually having clicked on a link. (Agreed that is notvery common among web browsers, but i've heard of mail clients doing that)

这篇关于是否有任何真正的原因POST区分和处理输入数据时,得到什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆