0

I am using curl in php

how can i use delete request using curl?

this is my code:

<?php

$ch = curl_init('http://192.168.236.44/confbridges/1.json');


curl_exec($ch);

if(!curl_errno($ch))
{
 $info = curl_getinfo($ch);

}

curl_close($ch);
?>

1 Answer 1

4

You need to add CURLOPT_CUSTOMREQUEST for DELETE request as:

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

From PHP Manual:

A custom request method to use instead of "GET" or "HEAD" when doing a HTTP request. This is useful for doing "DELETE" or other, more obscure HTTP requests. Valid values are things like "GET", "POST", "CONNECT" and so on; i.e. Do not enter a whole HTTP request line here. For instance, entering "GET /index.html HTTP/1.0\r\n\r\n" would be incorrect.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.