1

I have this line

$data['name'] = $this->put('name');

Apart from $_GET & $_POST in PHP, I have come across this for very first time. Somebody also told me just like GET & POST, there's also a PUT and DELETE.

I just want a basic difference between these four, I already know about the some basic differences between GET & POST. Any external links will also be helpful.

user1601973
  • 572
  • 1
  • 6
  • 24

1 Answers1

-1

From Wikipedia:

GET - Requests a representation of the specified resource. Requests using GET should only retrieve data and should have no other effect. (This is also true of some other HTTP methods.)[1] The W3C has published guidance principles on this distinction, saying, "Web application design should be informed by the above principles, but also by the relevant limitations."[11] See safe methods below.

POST - Submits data to be processed (e.g., from an HTML form) to the identified resource. The data is included in the body of the request. This may result in the creation of a new resource or the updates of existing resources or both.

PUT - Uploads a representation of the specified resource.

DELETE - Deletes the specified resource.

This, however, doesn't really give you a feel for when to use PUT and DELETE. I found that one of the best ways to get my head round what they do was to tinker with CouchDB. If you're not familiar with it, it's a non-relational database that you access via HTTP.

In CouchDB, you use GET to fetch data, POST to update data, PUT to insert data, and DELETE to delete data. If you'd like to explore it, there's a very good book about it at http://guide.couchdb.org/draft/. Going through http://guide.couchdb.org/draft/tour.html and http://guide.couchdb.org/draft/api.html may give you a good idea of how it works.

Community
  • 1
  • 1
Matthew Daly
  • 9,212
  • 2
  • 42
  • 83
  • I was interested in knowing about PUT and delete in Codeigniter. Well, this information is helpful too :) – user1601973 Aug 29 '12 at 18:07
  • Unless it's changed very recently, or there's a third-party library you're using that I'm unfamiliar with and that supports it, CodeIgniter doesn't really support HTTP PUT and DELETE requests properly - certainly the Input class doesn't support retrieving parameters submitted via PUT or DELETE. I tend to just use GET and POST if I'm building a RESTful web service using CodeIgniter. Microframeworks tend to have much better support for PUT and DELETE - I've used Slim recently, and that worked well. – Matthew Daly Aug 29 '12 at 18:22
  • Having just checked, there is a RESTful server implementation for CodeIgniter at https://github.com/philsturgeon/codeigniter-restserver that supports PUT and DELETE, so that might be worth checking out. – Matthew Daly Aug 29 '12 at 18:33