Reputation: 157
file_get_contents method can do a GET or POST request. I am wondering if it is possible to do a DELETE request with this method. I tried like below but it doesn't seem to do a DELETE Request. I am also not getting any error or exception. Is this possible?
$postdata = http_build_query($param);
$opts = array('http' =>
array(
'method' => 'DELETE',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
Upvotes: 2
Views: 3467
Reputation: 39
$result = file_get_contents( 'http://example.com/submit.php', false, stream_context_create(array( 'http' => array( 'method' => 'DELETE' ) )) );
Upvotes: 3