file_get_contents方法可以执行GET或POST请求。我想知道是否可以使用此方法执行DELETE请求。我尝试过如下,但它似乎没有做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);
答案 0 :(得分:1)
$ result = file_get_contents( 'http://example.com/submit.php', 假, stream_context_create(阵列( 'http'=>阵列( 'method'=> '删除' ) )) );