jtiu4q
Last Updated: February 25, 2016
·
6.673K
· marlonlandaverde
Af5d5e0da79c751e743c4a634dc0bb16

Sending PUT data through PHP cURL

For PHP Developers, trying to write a RESTful API can sometimes get a little clunky, especially when you're working with PUT. Here's how send a PUT request using cURL in PHP:

$data = array("woo" => "coderwall");

$ch = curl_init();

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$response = curl_exec($ch);
Say Thanks
Respond