2
file_get_contents方法可以执行GET或POST请求。我想知道是否有可能使用此方法执行DELETE请求。我尝试了下面的内容,但似乎没有执行DELETE请求。我也没有得到任何错误或例外。这可能吗?使用file_get_contents删除请求
$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);
您可能需要使用curl - 对于不返回正文*的HTTP请求,我认为使用'file_get_contents'不合理。 –
如果我的主机不提供卷曲怎么办?我想知道如果这是可能的与PHP不添加任何扩展名 – user1346107