• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

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

        時(shí)間:2024-10-15 13:52:13 PHP 我要投稿
        • 相關(guān)推薦

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

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

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

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

          3.fopen / file_get_contents 函數(shù)會受到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í)會把結(jié)果都存在一個(gè)字符串中 fiels函數(shù)則會儲存成數(shù)組形式

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

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

        PHP中curl的使用實(shí)例07-31

        PHP中的排序函數(shù)區(qū)別分析08-23

        PHP的cURL庫有效地抓網(wǎng)頁的技巧08-08

        探討PHP函數(shù)的實(shí)現(xiàn)原理及性能07-07

        簡單分析PHP中序列化用法介紹08-15

        PHP對象注入的實(shí)例分析08-27

        PHP中關(guān)于類的定義10-02

        php中session的實(shí)現(xiàn)原理以及大網(wǎng)站應(yīng)用應(yīng)注意的問題分析07-26

        PHP中函數(shù)的使用說明09-01

        如何使用PHP構(gòu)建一個(gè)高性能的彈幕后端服務(wù)01-22

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 亚洲综合免费的视频 | 亚洲热线99精品视频 | 日本综合AⅤ精品视频 | 日韩精品加勒比在线观看 | 亚洲国产一区二区三区 | 一本久道久久综合婷婷 |