据我所知,有三种类型:
不要使用GET和POST 不要使用POST而使用GET 你用哪一个都不重要。
我对这三种情况的假设正确吗?如果有,每个案例都有哪些例子?
据我所知,有三种类型:
不要使用GET和POST 不要使用POST而使用GET 你用哪一个都不重要。
我对这三种情况的假设正确吗?如果有,每个案例都有哪些例子?
当前回答
从w3schools.com:
What is HTTP? The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content. Two HTTP Request Methods: GET and POST Two commonly used methods for a request-response between a client and server are: GET and POST. GET – Requests data from a specified resource POST – Submits data to be processed to a specified resource
在这里我们区分主要的区别:
其他回答
当您希望URL反映页面的状态时,请使用GET。这对于查看动态生成的页面非常有用,比如这里看到的页面。POST应该在表单中用来提交数据,就像我点击“POST Your Answer”按钮一样。它还生成了一个更干净的URL,因为它没有在路径后生成参数字符串。
我不认为使用get有什么问题,我用它来做一些简单的事情,在查询字符串上保留东西是有意义的。
使用它来更新状态-像delete.php的GET ?Id =5删除一个页面是非常危险的。人们发现,当谷歌的网络加速器开始在页面上预取url时,它会击中所有的“删除”链接,并清除人们的数据。同样的事情也会发生在搜索引擎蜘蛛身上。
在PHP中,POST数据限制通常由PHP .ini设置。GET受到服务器/浏览器设置的限制——通常在255字节左右。
POST可以移动大数据,而GET不能。
但一般来说,这不是关于GET的缺点,而是一种惯例,如果你想让你的网站/web应用程序表现良好。
看看http://www.w3.org/2001/tag/doc/whenToUseGet.html
Gorgapor, mod_rewrite仍然经常使用GET。它只是允许将一个更友好的URL转换为一个带有GET查询字符串的URL。