亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

搜索

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

原創(chuàng) 2017-02-14 09:26:22 495
摘要:本文實(shí)例講述了php采用file_get_contents代替使用curl的方法,分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:file_get_contents代替使用curl其實(shí)不多見了,但有時(shí)你碰到服務(wù)器不支持curl時(shí)我們可以使用file_get_contents代替使用curl,下面看個(gè)例子。當(dāng)用盡一切辦法發(fā)現(xiàn) 服務(wù)器真的無法使用curl時(shí)。或者curl不支持https時(shí)。curl https

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

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

當(dāng)用盡一切辦法發(fā)現(xiàn) 服務(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 替代如下:

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));
}

更多關(guān)于php采用file_get_contents代替使用curl實(shí)例請(qǐng)關(guān)注PHP中文網(wǎng)(ipnx.cn)其他文章!

發(fā)布手記

熱門詞條