php - 使用 file_get_contents 删除请求

标签 php file-get-contents http-delete

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/

相关文章:

PHP 无法从 URL 获取文本(file_get_content,CURL 不起作用)

android - http删除tomcat 403错误

php - 非常简单的插入功能,没有存储数据,也没有收到错误

php - 我应该如何通过 AJAX 发出长 PHP 请求,定期检查状态更新,并在请求取消时关闭脚本?

php - 是否可以使用 PHP 在网页中显示 RTF 文件?

regex - 在两个字符串Powershell之间替换文本

javascript - 删除本地存储数据的方法有哪些?

php - 从 Javascript 数组中抓取?

javascript - 使用react redux获取删除请求方法不会删除

javascript - Node/Express - 如何实现 DELETE 和 PUT 请求