Creating and sending a request with a custom method
suggest changeThe cURL extension sends a GET request unless another method is set. CURLOPT_CUSTOMREQUEST sets the method, including DELETE, PUT, PATCH, or a non-standard method.
$method = 'DELETE'; // Create a DELETE request
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
$content = curl_exec($ch);
curl_close($ch);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents