1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. php中file-get-contents與curl性能比較分析的內(nèi)容

        時(shí)間:2020-11-24 19:50:02 PHP 我要投稿

        php中file-get-contents與curl性能比較分析的內(nèi)容

          PHP中fopen,file_get_contents,curl函數(shù)的區(qū)別:

          1.fopen /file_get_contents 每次請求都會(huì)重新做DNS查詢,并不對(duì) DNS信息進(jìn)行緩存。但是CURL會(huì)自動(dòng)對(duì)DNS信息進(jìn)行緩存。對(duì)同一域名下的網(wǎng)頁或者圖片的請求只需要一次DNS查詢。這大大減少了DNS查詢的次數(shù)。所以CURL的性能比fopen /file_get_contents 好很多。

          2.fopen /file_get_contents 在請求HTTP時(shí),使用的'是http_fopen_wrapper,不會(huì)keeplive。而curl卻可以。這樣在多次請求多個(gè)鏈接時(shí),curl效率會(huì)好一些。

          3.fopen / file_get_contents 函數(shù)會(huì)受到php.ini文件中allow_url_open選項(xiàng)配置的影響。如果該配置關(guān)閉了,則該函數(shù)也就失效了。而curl不受該配置的影響。

          4.curl 可以模擬多種請求,例如:POST數(shù)據(jù),表單提交等,用戶可以按照自己的需求來定制請求。而fopen / file_get_contents只能使用get方式獲取數(shù)據(jù)。

          file_get_contents 獲取遠(yuǎn)程文件時(shí)會(huì)把結(jié)果都存在一個(gè)字符串中 fiels函數(shù)則會(huì)儲(chǔ)存成數(shù)組形式

          因此,我還是比較傾向于使用curl來訪問遠(yuǎn)程url。Php有curl模塊擴(kuò)展,功能很是強(qiáng)大。

        【php中file-get-contents與curl性能比較分析的內(nèi)容】相關(guān)文章:

        1.PHP中curl的使用實(shí)例

        2.linux中php如何安裝CURL

        3.解決PHP中file-get-contents函數(shù)的方法

        4.php中instanceof 與 isa區(qū)別分析

        5.PHP中使用curl方法介紹

        6.PHP Curl多線程原理詳解

        7.PHP CURL內(nèi)存泄露的解決方法

        8.Oracle性能分析與優(yōu)化

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>