国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

php采用file_get_contents代替使用curl實例

2024-05-04 23:27:02
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了php采用file_get_contents代替使用curl的方法,實例講述了file_get_contents模擬curl的post方法,對于服務器不支持curl的情況來說有一定的借鑒價值,需要的朋友可以參考下
 
 

本文實例講述了php采用file_get_contents代替使用curl的方法,分享給大家供大家參考。具體實現方法如下:

file_get_contents代替使用curl其實不多見了,但有時你碰到服務器不支持curl時我們可以使用file_get_contents代替使用curl,下面看個例子。

當用盡一切辦法發現 服務器真的無法使用curl時。或者curl不支持https時。curl https 出現502時。你又不想重裝網站環境的時候,你就改用file_get_contents 代替吧。
curl 經常使用的 curl get curl post
curl get 替代 直接用file_get_contents($url) 就可以了
curl post 替代如下:

 

復制代碼代碼如下:
function Post($url, $post = null) {       
        $content = http_build_query($post);
        $content_length = strlen($content);
        $options = array(
            'http' => array(
                'method' => 'POST',
                'header' =>"Content-type: application/x-www-form-urlencoded",
                'content' => $post
            )
        );
        return file_get_contents($url, false, stream_context_create($options));
}

 

希望本文所述對大家的php程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 郎溪县| 霍州市| 寿宁县| 奈曼旗| 康保县| 桦南县| 屏东市| 张家港市| 印江| 安陆市| 滨州市| 湛江市| 额济纳旗| 大足县| 眉山市| 磴口县| 肥乡县| 岳阳市| 兴国县| 青岛市| 呼伦贝尔市| 郁南县| 黄陵县| 武夷山市| 高清| 天长市| 镇远县| 九台市| 腾冲县| 双鸭山市| 武隆县| 渝中区| 洞口县| 金川县| 栾城县| 永兴县| 阿坝| 建宁县| 博罗县| 阿图什市| 常山县|