最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php采用file_get_contents代替使用curl實(shí)例

 更新時(shí)間:2014年11月07日 11:43:53   投稿:shichen2014  
這篇文章主要介紹了php采用file_get_contents代替使用curl的方法,實(shí)例講述了file_get_contents模擬curl的post方法,對(duì)于服務(wù)器不支持curl的情況來(lái)說(shuō)有一定的借鑒價(jià)值,需要的朋友可以參考下

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

file_get_contents代替使用curl其實(shí)不多見(jiàn)了,但有時(shí)你碰到服務(wù)器不支持curl時(shí)我們可以使用file_get_contents代替使用curl,下面看個(gè)例子。

當(dāng)用盡一切辦法發(fā)現(xiàn) 服務(wù)器真的無(wú)法使用curl時(shí)?;蛘遚url不支持https時(shí)。curl https 出現(xiàn)502時(shí)。你又不想重裝網(wǎng)站環(huán)境的時(shí)候,你就改用file_get_contents 代替吧。
curl 經(jīng)常使用的 curl get curl post
curl get 替代 直接用file_get_contents($url) 就可以了
curl post 替代如下:

復(fù)制代碼 代碼如下:
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));
}

希望本文所述對(duì)大家的php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

郧西县| 左云县| 宁乡县| 永春县| 昔阳县| 登封市| 阳信县| 抚州市| 北票市| 西青区| 许昌市| 平和县| 会昌县| 宜宾县| 南岸区| 施秉县| 策勒县| 盐源县| 尤溪县| 石首市| 五原县| 碌曲县| 开阳县| 抚松县| 云龙县| 惠东县| 阿荣旗| 天峨县| 澎湖县| 牟定县| 井冈山市| 玉山县| 龙江县| 彭水| 潼南县| 阜宁县| 得荣县| 鹤岗市| 洞头县| 卢氏县| 大竹县|