{"id":270,"date":"2010-03-17T10:21:49","date_gmt":"2010-03-17T10:21:49","guid":{"rendered":""},"modified":"2010-03-17T10:21:49","modified_gmt":"2010-03-17T10:21:49","slug":"270","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=270","title":{"rendered":"PHP\u4e2d\u7684CURL\u51fd\u6570\u5e93"},"content":{"rendered":"<p>\u76ee\u524d\u4e3a\u76ee\u6700\u5168\u7684CURL\u4e2d\u6587\u8bf4\u660e\u4e86,\u5b66PHP\u7684\u8981\u597d\u597d\u638c\u63e1.\u6709\u5f88\u591a\u7684\u53c2\u6570.\u5927\u90e8\u4efd\u90fd\u5f88\u6709\u7528.\u771f\u6b63\u638c\u63e1\u4e86\u5b83\u548c\u6b63\u5219,\u4e00\u5b9a\u5c31\u662f\u4e2a\u91c7\u96c6\u9ad8\u624b\u4e86.<\/p>\n<p>PHP\u4e2d\u7684CURL\u51fd\u6570\u5e93\uff08Client URL Library Function\uff09<\/p>\n<p>curl_close \u2014 \u5173\u95ed\u4e00\u4e2acurl\u4f1a\u8bdd<br \/>curl_copy_handle \u2014 \u62f7\u8d1d\u4e00\u4e2acurl\u8fde\u63a5\u8d44\u6e90\u7684\u6240\u6709\u5185\u5bb9\u548c\u53c2\u6570<br \/>curl_errno \u2014 \u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5f53\u524d\u4f1a\u8bdd\u9519\u8bef\u4fe1\u606f\u7684\u6570\u5b57\u7f16\u53f7<br \/>curl_error \u2014 \u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5f53\u524d\u4f1a\u8bdd\u9519\u8bef\u4fe1\u606f\u7684\u5b57\u7b26\u4e32<br \/>curl_exec \u2014 \u6267\u884c\u4e00\u4e2acurl\u4f1a\u8bdd<br \/>curl_getinfo \u2014 \u83b7\u53d6\u4e00\u4e2acurl\u8fde\u63a5\u8d44\u6e90\u53e5\u67c4\u7684\u4fe1\u606f<br \/>curl_init \u2014 \u521d\u59cb\u5316\u4e00\u4e2acurl\u4f1a\u8bdd<br \/>curl_multi_add_handle \u2014 \u5411curl\u6279\u5904\u7406\u4f1a\u8bdd\u4e2d\u6dfb\u52a0\u5355\u72ec\u7684curl\u53e5\u67c4\u8d44\u6e90<br \/>curl_multi_close \u2014 \u5173\u95ed\u4e00\u4e2a\u6279\u5904\u7406\u53e5\u67c4\u8d44\u6e90<br \/>curl_multi_exec \u2014 \u89e3\u6790\u4e00\u4e2acurl\u6279\u5904\u7406\u53e5\u67c4<br \/>curl_multi_getcontent \u2014 \u8fd4\u56de\u83b7\u53d6\u7684\u8f93\u51fa\u7684\u6587\u672c\u6d41<br \/>curl_multi_info_read \u2014 \u83b7\u53d6\u5f53\u524d\u89e3\u6790\u7684curl\u7684\u76f8\u5173\u4f20\u8f93\u4fe1\u606f<br \/>curl_multi_init \u2014 \u521d\u59cb\u5316\u4e00\u4e2acurl\u6279\u5904\u7406\u53e5\u67c4\u8d44\u6e90<br \/>curl_multi_remove_handle \u2014 \u79fb\u9664curl\u6279\u5904\u7406\u53e5\u67c4\u8d44\u6e90\u4e2d\u7684\u67d0\u4e2a\u53e5\u67c4\u8d44\u6e90<br \/>curl_multi_select \u2014 Get all the sockets associated with the cURL extension, which can then be &#8220;selected&#8221;<br \/>curl_setopt_array \u2014 \u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u4e3a\u4e00\u4e2acurl\u8bbe\u7f6e\u4f1a\u8bdd\u53c2\u6570<br \/>curl_setopt \u2014 \u4e3a\u4e00\u4e2acurl\u8bbe\u7f6e\u4f1a\u8bdd\u53c2\u6570<br \/>curl_version \u2014 \u83b7\u53d6curl\u76f8\u5173\u7684\u7248\u672c\u4fe1\u606f<\/p>\n<p>curl_init()\u51fd\u6570\u7684\u4f5c\u7528\u521d\u59cb\u5316\u4e00\u4e2acurl\u4f1a\u8bdd\uff0ccurl_init()\u51fd\u6570\u552f\u4e00\u7684\u4e00\u4e2a\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u8868\u793a\u4e00\u4e2aurl\u5730\u5740\u3002<br \/>curl_exec()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u6267\u884c\u4e00\u4e2acurl\u4f1a\u8bdd\uff0c\u552f\u4e00\u7684\u53c2\u6570\u662fcurl_init()\u51fd\u6570\u8fd4\u56de\u7684\u53e5\u67c4\u3002<br \/>curl_close()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u5173\u95ed\u4e00\u4e2acurl\u4f1a\u8bdd\uff0c\u552f\u4e00\u7684\u53c2\u6570\u662fcurl_init()\u51fd\u6570\u8fd4\u56de\u7684\u53e5\u67c4\u3002<\/p>\n<p>&lt;?php<br \/>$ch = curl_init(&#8220;<a href=\"http:\/\/www.baidu.com\/\" target=\"_blank\" rel=\"external\">http:\/\/www.baidu.com\/<\/a>&#8220;);<br \/>curl_exec($ch);<br \/>curl_close($ch);<br \/>?&gt;<br \/>curl_version()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u83b7\u53d6curl\u76f8\u5173\u7684\u7248\u672c\u4fe1\u606f\uff0ccurl_version()\u51fd\u6570\u6709\u4e00\u4e2a\u53c2\u6570\uff0c\u4e0d\u6e05\u695a\u662f\u505a\u4ec0\u4e48\u7684<\/p>\n<p>&lt;?php<br \/>print_r(curl_version())<br \/>?&gt;<br \/>curl_getinfo()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u83b7\u53d6\u4e00\u4e2acurl\u8fde\u63a5\u8d44\u6e90\u53e5\u67c4\u7684\u4fe1\u606f\uff0ccurl_getinfo()\u51fd\u6570\u6709\u4e24\u4e2a\u53c2\u6570\uff0c\u7b2c\u4e00\u4e2a\u53c2\u6570\u662fcurl\u7684\u8d44\u6e90\u53e5\u67c4\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u4e0b\u9762\u4e00\u4e9b\u5e38\u91cf\uff1a<\/p>\n<p>&lt;?php<br \/>$ch = curl_init(&#8220;<a href=\"http:\/\/www.baidu.com\/\" target=\"_blank\" rel=\"external\">http:\/\/www.baidu.com\/<\/a>&#8220;);<br \/>print_r(curl_getinfo($ch));<br \/>?&gt;<br \/>\u53ef\u9009\u7684\u5e38\u91cf\u5305\u62ec\uff1a<\/p>\n<p>CURLINFO_EFFECTIVE_URL<br \/>\u6700\u540e\u4e00\u4e2a\u6709\u6548\u7684url\u5730\u5740<\/p>\n<p>CURLINFO_HTTP_CODE<br \/>\u6700\u540e\u4e00\u4e2a\u6536\u5230\u7684HTTP\u4ee3\u7801<\/p>\n<p>CURLINFO_FILETIME<br \/>\u8fdc\u7a0b\u83b7\u53d6\u6587\u6863\u7684\u65f6\u95f4\uff0c\u5982\u679c\u65e0\u6cd5\u83b7\u53d6\uff0c\u5219\u8fd4\u56de\u503c\u4e3a\u201c-1\u201d<\/p>\n<p>CURLINFO_TOTAL_TIME<br \/>\u6700\u540e\u4e00\u6b21\u4f20\u8f93\u6240\u6d88\u8017\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_NAMELOOKUP_TIME<br \/>\u540d\u79f0\u89e3\u6790\u6240\u6d88\u8017\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_CONNECT_TIME<br \/>\u5efa\u7acb\u8fde\u63a5\u6240\u6d88\u8017\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_PRETRANSFER_TIME<br \/>\u4ece\u5efa\u7acb\u8fde\u63a5\u5230\u51c6\u5907\u4f20\u8f93\u6240\u4f7f\u7528\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_STARTTRANSFER_TIME<br \/>\u4ece\u5efa\u7acb\u8fde\u63a5\u5230\u4f20\u8f93\u5f00\u59cb\u6240\u4f7f\u7528\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_REDIRECT_TIME<br \/>\u5728\u4e8b\u52a1\u4f20\u8f93\u5f00\u59cb\u524d\u91cd\u5b9a\u5411\u6240\u4f7f\u7528\u7684\u65f6\u95f4<\/p>\n<p>CURLINFO_SIZE_UPLOAD<br \/>\u4e0a\u4f20\u6570\u636e\u91cf\u7684\u603b\u503c<\/p>\n<p>CURLINFO_SIZE_DOWNLOAD<br \/>\u4e0b\u8f7d\u6570\u636e\u91cf\u7684\u603b\u503c<\/p>\n<p>CURLINFO_SPEED_DOWNLOAD<br \/>\u5e73\u5747\u4e0b\u8f7d\u901f\u5ea6<\/p>\n<p>CURLINFO_SPEED_UPLOAD<br \/>\u5e73\u5747\u4e0a\u4f20\u901f\u5ea6<\/p>\n<p>CURLINFO_HEADER_SIZE<br \/>header\u90e8\u5206\u7684\u5927\u5c0f<\/p>\n<p>CURLINFO_HEADER_OUT<br \/>\u53d1\u9001\u8bf7\u6c42\u7684\u5b57\u7b26\u4e32<\/p>\n<p>CURLINFO_REQUEST_SIZE<br \/>\u5728HTTP\u8bf7\u6c42\u4e2d\u6709\u95ee\u9898\u7684\u8bf7\u6c42\u7684\u5927\u5c0f<\/p>\n<p>CURLINFO_SSL_VERIFYRESULT<br \/>Result of SSL certification verification requested by setting CURLOPT_SSL_VERIFYPEER<\/p>\n<p>CURLINFO_CONTENT_LENGTH_DOWNLOAD<br \/>\u4eceContent-Length: field\u4e2d\u8bfb\u53d6\u7684\u4e0b\u8f7d\u5185\u5bb9\u957f\u5ea6<\/p>\n<p>CURLINFO_CONTENT_LENGTH_UPLOAD<br \/>\u4e0a\u4f20\u5185\u5bb9\u5927\u5c0f\u7684\u8bf4\u660e<\/p>\n<p>CURLINFO_CONTENT_TYPE<br \/>\u4e0b\u8f7d\u5185\u5bb9\u7684\u201cContent-type\u201d\u503c\uff0cNULL\u8868\u793a\u670d\u52a1\u5668\u6ca1\u6709\u53d1\u9001\u6709\u6548\u7684\u201cContent-Type: header\u201d<\/p>\n<p>curl_setopt()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u4e3a\u4e00\u4e2acurl\u8bbe\u7f6e\u4f1a\u8bdd\u53c2\u6570\u3002curl_setopt_array()\u51fd\u6570\u7684\u4f5c\u7528\u662f\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u4e3a\u4e00\u4e2acurl\u8bbe\u7f6e\u4f1a\u8bdd\u53c2\u6570\u3002<\/p>\n<p>&lt;?php<br \/>$ch = curl_init();<br \/>$fp = fopen(&#8220;example_homepage.txt&#8221;, &#8220;w&#8221;);<br \/>curl_setopt($ch, CURLOPT_FILE, $fp);<br \/>$options = array(<br \/>CURLOPT_URL =&gt; &#8216;<a href=\"http:\/\/www.baidu.com\/\" target=\"_blank\" rel=\"external\">http:\/\/www.baidu.com\/<\/a>&#8216;,<br \/>CURLOPT_HEADER =&gt; false<br \/>);<br \/>curl_setopt_array($ch, $options);<br \/>curl_exec($ch);<br \/>curl_close($ch);<br \/>fclose($fp);<br \/>?&gt;<br \/>\u53ef\u8bbe\u7f6e\u7684\u53c2\u6570\u6709\uff1a<\/p>\n<p>CURLOPT_AUTOREFERER<br \/>\u81ea\u52a8\u8bbe\u7f6eheader\u4e2d\u7684referer\u4fe1\u606f<\/p>\n<p>CURLOPT_BINARYTRANSFER<br \/>\u5728\u542f\u7528CURLOPT_RETURNTRANSFER\u65f6\u5019\u5c06\u83b7\u53d6\u6570\u636e\u8fd4\u56de<\/p>\n<p>CURLOPT_COOKIESESSION<br \/>\u542f\u7528\u65f6curl\u4f1a\u4ec5\u4ec5\u4f20\u9012\u4e00\u4e2asession cookie\uff0c\u5ffd\u7565\u5176\u4ed6\u7684cookie\uff0c\u9ed8\u8ba4\u72b6\u51b5\u4e0bcurl\u4f1a\u5c06\u6240\u6709\u7684cookie\u8fd4\u56de\u7ed9\u670d\u52a1\u7aef\u3002session cookie\u662f\u6307\u90a3\u4e9b\u7528\u6765\u5224\u65ad\u670d\u52a1\u5668\u7aef\u7684session\u662f\u5426\u6709\u6548\u800c\u5b58\u5728\u7684cookie\u3002<\/p>\n<p>CURLOPT_CRLF<br \/>\u542f\u7528\u65f6\u5c06Unix\u7684\u6362\u884c\u7b26\u8f6c\u6362\u6210\u56de\u8f66\u6362\u884c\u7b26\u3002<\/p>\n<p>CURLOPT_DNS_USE_GLOBAL_CACHE<br \/>\u542f\u7528\u65f6\u4f1a\u542f\u7528\u4e00\u4e2a\u5168\u5c40\u7684DNS\u7f13\u5b58\uff0c\u6b64\u9879\u4e3a\u7ebf\u7a0b\u5b89\u5168\u7684\uff0c\u5e76\u4e14\u9ed8\u8ba4\u4e3atrue\u3002<\/p>\n<p>CURLOPT_FAILONERROR<br \/>\u663e\u793aHTTP\u72b6\u6001\u7801\uff0c\u9ed8\u8ba4\u884c\u4e3a\u662f\u5ffd\u7565\u7f16\u53f7\u5c0f\u4e8e\u7b49\u4e8e400\u7684HTTP\u4fe1\u606f<\/p>\n<p>CURLOPT_FILETIME<br \/>\u542f\u7528\u65f6\u4f1a\u5c1d\u8bd5\u4fee\u6539\u8fdc\u7a0b\u6587\u6863\u4e2d\u7684\u4fe1\u606f\u3002\u7ed3\u679c\u4fe1\u606f\u4f1a\u901a\u8fc7curl_getinfo()\u51fd\u6570\u7684CURLINFO_FILETIME\u9009\u9879\u8fd4\u56de\u3002<\/p>\n<p>CURLOPT_FOLLOWLOCATION<br \/>\u542f\u7528\u65f6\u4f1a\u5c06\u670d\u52a1\u5668\u670d\u52a1\u5668\u8fd4\u56de\u7684\u201cLocation:\u201d\u653e\u5728header\u4e2d\u9012\u5f52\u7684\u8fd4\u56de\u7ed9\u670d\u52a1\u5668\uff0c\u4f7f\u7528CURLOPT_MAXREDIRS\u53ef\u4ee5\u9650\u5b9a\u9012\u5f52\u8fd4\u56de\u7684\u6570\u91cf\u3002<\/p>\n<p>CURLOPT_FORBID_REUSE<br \/>\u5728\u5b8c\u6210\u4ea4\u4e92\u4ee5\u540e\u5f3a\u8feb\u65ad\u5f00\u8fde\u63a5\uff0c\u4e0d\u80fd\u91cd\u7528\u3002<\/p>\n<p>CURLOPT_FRESH_CONNECT<br \/>\u5f3a\u5236\u83b7\u53d6\u4e00\u4e2a\u65b0\u7684\u8fde\u63a5\uff0c\u66ff\u4ee3\u7f13\u5b58\u4e2d\u7684\u8fde\u63a5\u3002<\/p>\n<p>CURLOPT_FTP_USE_EPRT<br \/>TRUE to use EPRT (and LPRT) when doing active FTP downloads. Use FALSE to disable EPRT and LPRT and use PORT only.<br \/>Added in PHP 5.0.0.<\/p>\n<p>CURLOPT_FTP_USE_EPSV<br \/>TRUE to first try an EPSV command for FTP transfers before reverting back to PASV. Set to FALSE to disable EPSV.<\/p>\n<p>CURLOPT_FTPAPPEND<br \/>TRUE to append to the remote file instead of overwriting it.<\/p>\n<p>CURLOPT_FTPASCII<br \/>An alias of CURLOPT_TRANSFERTEXT. Use that instead.<\/p>\n<p>CURLOPT_FTPLISTONLY<br \/>TRUE to only list the names of an FTP directory.<\/p>\n<p>CURLOPT_HEADER<br \/>\u542f\u7528\u65f6\u4f1a\u5c06\u5934\u6587\u4ef6\u7684\u4fe1\u606f\u4f5c\u4e3a\u6570\u636e\u6d41\u8f93\u51fa\u3002<\/p>\n<p>CURLOPT_HTTPGET<br \/>\u542f\u7528\u65f6\u4f1a\u8bbe\u7f6eHTTP\u7684method\u4e3aGET\uff0c\u56e0\u4e3aGET\u662f\u9ed8\u8ba4\u662f\uff0c\u6240\u4ee5\u53ea\u5728\u88ab\u4fee\u6539\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/p>\n<p>CURLOPT_HTTPPROXYTUNNEL<br \/>\u542f\u7528\u65f6\u4f1a\u901a\u8fc7HTTP\u4ee3\u7406\u6765\u4f20\u8f93\u3002<\/p>\n<p>CURLOPT_MUTE<br \/>\u8bb2curl\u51fd\u6570\u4e2d\u6240\u6709\u4fee\u6539\u8fc7\u7684\u53c2\u6570\u6062\u590d\u9ed8\u8ba4\u503c\u3002<\/p>\n<p>CURLOPT_NETRC<br \/>\u5728\u8fde\u63a5\u5efa\u7acb\u4ee5\u540e\uff0c\u8bbf\u95ee~\/.netrc\u6587\u4ef6\u83b7\u53d6\u7528\u6237\u540d\u548c\u5bc6\u7801\u4fe1\u606f\u8fde\u63a5\u8fdc\u7a0b\u7ad9\u70b9\u3002<\/p>\n<p>CURLOPT_NOBODY<br \/>\u542f\u7528\u65f6\u5c06\u4e0d\u5bf9HTML\u4e2d\u7684body\u90e8\u5206\u8fdb\u884c\u8f93\u51fa\u3002<\/p>\n<p>CURLOPT_NOPROGRESS<br \/>\u542f\u7528\u65f6\u5173\u95edcurl\u4f20\u8f93\u7684\u8fdb\u5ea6\u6761\uff0c\u6b64\u9879\u7684\u9ed8\u8ba4\u8bbe\u7f6e\u4e3atrue<\/p>\n<p>CURLOPT_NOSIGNAL<br \/>\u542f\u7528\u65f6\u5ffd\u7565\u6240\u6709\u7684curl\u4f20\u9012\u7ed9php\u8fdb\u884c\u7684\u4fe1\u53f7\u3002\u5728SAPI\u591a\u7ebf\u7a0b\u4f20\u8f93\u65f6\u6b64\u9879\u88ab\u9ed8\u8ba4\u6253\u5f00\u3002<\/p>\n<p>CURLOPT_POST<br \/>\u542f\u7528\u65f6\u4f1a\u53d1\u9001\u4e00\u4e2a\u5e38\u89c4\u7684POST\u8bf7\u6c42\uff0c\u7c7b\u578b\u4e3a\uff1aapplication\/x-www-form-urlencoded\uff0c\u5c31\u50cf\u8868\u5355\u63d0\u4ea4\u7684\u4e00\u6837\u3002<\/p>\n<p>CURLOPT_PUT<br \/>\u542f\u7528\u65f6\u5141\u8bb8HTTP\u53d1\u9001\u6587\u4ef6\uff0c\u5fc5\u987b\u540c\u65f6\u8bbe\u7f6eCURLOPT_INFILE\u548cCURLOPT_INFILESIZE<\/p>\n<p>CURLOPT_RETURNTRANSFER<br \/>\u8bb2curl_exec()\u83b7\u53d6\u7684\u4fe1\u606f\u4ee5\u6587\u4ef6\u6d41\u7684\u5f62\u5f0f\u8fd4\u56de\uff0c\u800c\u4e0d\u662f\u76f4\u63a5\u8f93\u51fa\u3002<\/p>\n<p>CURLOPT_SSL_VERIFYPEER<br \/>FALSE to stop cURL from verifying the peer&#8217;s certificate. Alternate certificates to verify against can be specified with the CURLOPT_CAINFO option or a certificate directory can be specified with the CURLOPT_CAPATH option. CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2). TRUE by default as of cURL 7.10. Default bundle installed as of cURL 7.10.<\/p>\n<p>CURLOPT_TRANSFERTEXT<br \/>TRUE to use ASCII mode for FTP transfers. For LDAP, it retrieves data in plain text instead of HTML. On Windows systems, it will not set STDOUT to binary mode.<\/p>\n<p>CURLOPT_UNRESTRICTED_AUTH<br \/>\u5728\u4f7f\u7528CURLOPT_FOLLOWLOCATION\u4ea7\u751f\u7684header\u4e2d\u7684\u591a\u4e2alocations\u4e2d\u6301\u7eed\u8ffd\u52a0\u7528\u6237\u540d\u548c\u5bc6\u7801\u4fe1\u606f\uff0c\u5373\u4f7f\u57df\u540d\u5df2\u53d1\u751f\u6539\u53d8\u3002<\/p>\n<p>CURLOPT_UPLOAD<br \/>\u542f\u7528\u65f6\u5141\u8bb8\u6587\u4ef6\u4f20\u8f93<\/p>\n<p>CURLOPT_VERBOSE<br \/>\u542f\u7528\u65f6\u4f1a\u6c47\u62a5\u6240\u6709\u7684\u4fe1\u606f\uff0c\u5b58\u653e\u5728STDERR\u6216\u6307\u5b9a\u7684CURLOPT_STDERR\u4e2d<\/p>\n<p>CURLOPT_BUFFERSIZE<br \/>\u6bcf\u6b21\u83b7\u53d6\u7684\u6570\u636e\u4e2d\u8bfb\u5165\u7f13\u5b58\u7684\u5927\u5c0f\uff0c\u8fd9\u4e2a\u503c\u6bcf\u6b21\u90fd\u4f1a\u88ab\u586b\u6ee1\u3002<\/p>\n<p>CURLOPT_CLOSEPOLICY<br \/>\u4e0d\u662fCURLCLOSEPOLICY_LEAST_RECENTLY_USED\u5c31\u662fCURLCLOSEPOLICY_OLDEST\uff0c\u8fd8\u5b58\u5728\u53e6\u5916\u4e09\u4e2a\uff0c\u4f46\u662fcurl\u6682\u65f6\u8fd8\u4e0d\u652f\u6301\u3002.<\/p>\n<p>CURLOPT_CONNECTTIMEOUT<br \/>\u5728\u53d1\u8d77\u8fde\u63a5\u524d\u7b49\u5f85\u7684\u65f6\u95f4\uff0c\u5982\u679c\u8bbe\u7f6e\u4e3a0\uff0c\u5219\u4e0d\u7b49\u5f85\u3002<\/p>\n<p>CURLOPT_DNS_CACHE_TIMEOUT<br \/>\u8bbe\u7f6e\u5728\u5185\u5b58\u4e2d\u4fdd\u5b58DNS\u4fe1\u606f\u7684\u65f6\u95f4\uff0c\u9ed8\u8ba4\u4e3a120\u79d2\u3002<\/p>\n<p>CURLOPT_FTPSSLAUTH<br \/>The FTP authentication method (when is activated): CURLFTPAUTH_SSL (try SSL first), CURLFTPAUTH_TLS (try TLS first), or CURLFTPAUTH_DEFAULT (let cURL decide).<\/p>\n<p>CURLOPT_HTTP_VERSION<br \/>\u8bbe\u7f6ecurl\u4f7f\u7528\u7684HTTP\u534f\u8bae\uff0cCURL_HTTP_VERSION_NONE\uff08\u8ba9curl\u81ea\u5df1\u5224\u65ad\uff09\uff0cCURL_HTTP_VERSION_1_0\uff08HTTP\/1.0\uff09\uff0cCURL_HTTP_VERSION_1_1\uff08HTTP\/1.1\uff09<\/p>\n<p>CURLOPT_HTTPAUTH<br \/>\u4f7f\u7528\u7684HTTP\u9a8c\u8bc1\u65b9\u6cd5\uff0c\u53ef\u9009\u7684\u503c\u6709\uff1aCURLAUTH_BASIC\uff0cCURLAUTH_DIGEST\uff0cCURLAUTH_GSSNEGOTIATE\uff0cCURLAUTH_NTLM\uff0cCURLAUTH_ANY\uff0cCURLAUTH_ANYSAFE\uff0c\u53ef\u4ee5\u4f7f\u7528\u201c|\u201d\u64cd\u4f5c\u7b26\u5206\u9694\u591a\u4e2a\u503c\uff0ccurl\u8ba9\u670d\u52a1\u5668\u9009\u62e9\u4e00\u4e2a\u652f\u6301\u6700\u597d\u7684\u503c\uff0cCURLAUTH_ANY\u7b49\u4ef7\u4e8eCURLAUTH_BASIC | CURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM\uff0cCURLAUTH_ANYSAFE\u7b49\u4ef7\u4e8eCURLAUTH_DIGEST | CURLAUTH_GSSNEGOTIATE | CURLAUTH_NTLM<\/p>\n<p>CURLOPT_INFILESIZE<br \/>\u8bbe\u5b9a\u4e0a\u4f20\u6587\u4ef6\u7684\u5927\u5c0f<\/p>\n<p>CURLOPT_LOW_SPEED_LIMIT<br \/>\u5f53\u4f20\u8f93\u901f\u5ea6\u5c0f\u4e8eCURLOPT_LOW_SPEED_LIMIT\u65f6\uff0cPHP\u4f1a\u6839\u636eCURLOPT_LOW_SPEED_TIME\u6765\u5224\u65ad\u662f\u5426\u56e0\u592a\u6162\u800c\u53d6\u6d88\u4f20\u8f93\u3002<\/p>\n<p>CURLOPT_LOW_SPEED_TIME<br \/>The number of seconds the transfer should be below CURLOPT_LOW_SPEED_LIMIT for PHP to consider the transfer too slow and abort.<br \/>\u5f53\u4f20\u8f93\u901f\u5ea6\u5c0f\u4e8eCURLOPT_LOW_SPEED_LIMIT\u65f6\uff0cPHP\u4f1a\u6839\u636eCURLOPT_LOW_SPEED_TIME\u6765\u5224\u65ad\u662f\u5426\u56e0\u592a\u6162\u800c\u53d6\u6d88\u4f20\u8f93\u3002<\/p>\n<p>CURLOPT_MAXCONNECTS<br \/>\u5141\u8bb8\u7684\u6700\u5927\u8fde\u63a5\u6570\u91cf\uff0c\u8d85\u8fc7\u662f\u4f1a\u901a\u8fc7CURLOPT_CLOSEPOLICY\u51b3\u5b9a\u5e94\u8be5\u505c\u6b62\u54ea\u4e9b\u8fde\u63a5<\/p>\n<p>CURLOPT_MAXREDIRS<br \/>\u6307\u5b9a\u6700\u591a\u7684HTTP\u91cd\u5b9a\u5411\u7684\u6570\u91cf\uff0c\u8fd9\u4e2a\u9009\u9879\u662f\u548cCURLOPT_FOLLOWLOCATION\u4e00\u8d77\u4f7f\u7528\u7684\u3002<\/p>\n<p>CURLOPT_PORT<br \/>\u4e00\u4e2a\u53ef\u9009\u7684\u7528\u6765\u6307\u5b9a\u8fde\u63a5\u7aef\u53e3\u7684\u91cf <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u524d\u4e3a\u76ee\u6700\u5168\u7684CURL\u4e2d\u6587\u8bf4\u660e\u4e86,\u5b66PHP\u7684\u8981\u597d\u597d\u638c\u63e1.\u6709\u5f88\u591a\u7684\u53c2\u6570&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-270","post","type-post","status-publish","format-standard","hentry","category-Php"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/270","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=270"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/270\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}