file_get_contents 方法可以执行 GET 或 POST 请求。我想知道是否可以使用此方法执行 DELETE 请求。我尝试如下,但它似乎没有执行删除请求。我也没有收到任何错误或异常。这可能吗?
$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);
最佳答案
$结果 = file_get_contents( 'http://example.com/submit.php ', 错误的, 流上下文创建(数组( 'http' => 数组( '方法' => '删除' ) )) );
关于php - 使用 file_get_contents 删除请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19158178/