Home > php教程 > php手册 > body text

比一比才知道 GET vs POST

WBOY
Release: 2016-06-21 08:51:51
Original
1203 people have browsed it

  1,Get中数据大小被限制:我们都知道很多老式浏览器把URL的字符串个数被限制在255个之内;虽然现在的新版浏览器早就没有这个蛋疼的限制,但是我们可不敢保证所有来站点访问的用户都是使用新版浏览器的。所以当我们需要用户在网页中填写一些信息时,使用Get方式肯定会出问题。相反Post方法中没有这个限制,我们可以传输任意大小的数据。

  2,Get中的数据类型不灵活:因为Get是使用url来传输数据的,那么比如空格字符以及类似&这样的字符就不方便传输。我们可以使用发送前编码,以及接受后解码的方法来解决。

  3,安全性:在Get中,参数是以名值对的查询字符串挂接在url后缀来传输的,所以这个非常容易被浏览器历史记录中查询到。所有的数据也都是以文本方式提交,所以我们知道比如登录操作的密码是绝对不能使用Get方式来提交。

  相反,Post方法就安全多了。所有的名值对都是以消息体的方式在Http Request的方式传输。

  4,速度:显然Get比Post要快。

  5,书签:其实有几个情况下用Get更好,比如你能将名值对参数以书签的方式存储并直接在子啊表单中使用。但在Post下是无法做到的。

  6,以表单方式上传文件只能使用 Post 方式实现,Get几乎不可能。

  7,在服务器对Get方式提交的数据编码时可能会数据丢失。但对于Post是不会的。

  8,Get使用栈方法传输表单变量,而Post使用HEAP方法来传输表单变量。

  9,Get最多也就一次性传输18个参数而Post没有这个限制。



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!