php - laravel HTTP请求的疑问,put patch delete options存在的意义,已经应用场景是什么
PHP中文网
PHP中文网 2017-05-16 13:06:12
0
6
989

HTTP请求类型,put patch delete options这些有什么用?从来没用过啊。
平时开发都是get post请求,感觉get post完全可以进行Mysql的增删改查操作。
put patch delete options这几种类型有什么用处呢?应用场景是什么?应该怎么写呢?
get请求一般是url传参数,表单method当然也可以写get;
post请求一般是表单提交;

PHP中文网
PHP中文网

认证0级讲师

reply all(6)
巴扎黑

These are standard http predicates

  • GET Get resources

  • POST Create Resource

  • PUT edit/update resources (complete resource fields need to be submitted)

  • PATCH edit/update resources (you can submit fields that need to be updated)

  • DELETE Delete resources

  • OPTIONS Which request verbs are allowed by the server

过去多啦不再A梦

These are commonly used in the recently popular RestFul mode. In addition, HTML forms only support two request methods: POST and GET. PUT, PATCH and DELETE are fake HTTP request methods in Laravel. You need to add <input type="hidden" name="_method" value="PUT(PATCH、DELETE)"> to the form to take effect. Also Configure routing.

phpcn_u1582

http://www.imooc.com/learn/81...

曾经蜡笔没有小新

In fact, it is recommended to read "HTTP Authoritative Guide" and other similar books explaining HTTP to understand HTTP
You need to understand a few concepts,
1. These put and delete methods are not unique to laravel. In fact, all PHP frameworks should support it Of course, these frameworks do not support it. As mentioned in the question, GET and POST can satisfy the business
2. It is not unique to PHP. Any language that deals with HTTP should support it

我想大声告诉你

Search Restful and you will understand.

漂亮男人

Get and post can of course satisfy all operations.
Using put, patch and delete makes it look simpler and easier to understand.
patch /item/1 is to modify the data with id 1.
get /item/1 finds the data with id 1.
delete /item/1 deletes the data with id 1

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!