📄 context.curl.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>CURL context option listing</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="context.ssl.html">SSL context options</a></div> <div class="next" style="text-align: right; float: right;"><a href="context.params.html">Context parameters</a></div> <div class="up"><a href="context.html">Context options and parameters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="context.curl" class="refentry"> <div class="refnamediv"> <h1 class="refname">CURL context options</h1> <p class="refpurpose"><span class="refname">CURL context options</span> — <span class="dc-title">CURL context option listing</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <p class="para"> CURL context options are available when the <a href="intro.curl.html" class="link">CURL</a> extension was compiled using the <span class="option">--with-curlwrappers</span> configure option. </p> </div> <div class="refsect1 options"> <h3 class="title">Options</h3> <p class="para"> <dl> <dt id="context.curl.method"> <span class="term"> <i><tt class="parameter">method</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> <b><tt>GET</tt></b>, <b><tt>POST</tt></b>, or any other HTTP method supported by the remote server. </p> <p class="para"> Defaults to <b><tt>GET</tt></b>. </p> </dd> </dt> <dt id="context.curl.header"> <span class="term"> <i><tt class="parameter">header</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> Additional headers to be sent during request. Values in this option will override other values (such as <i>User-agent:</i>, <i>Host:</i>, and <i>Authentication:</i>). </p> </dd> </dt> <dt id="context.curl.user-agent"> <span class="term"> <i><tt class="parameter">user_agent</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> Value to send with User-Agent: header. </p> <p class="para"> By default the <a href="filesystem.configuration.html#ini.user-agent" class="link">user_agent</a> <var class="filename">php.ini</var> setting is used. </p> </dd> </dt> <dt id="context.curl.content"> <span class="term"> <i><tt class="parameter">content</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> Additional data to be sent after the headers. This option is not used for <b><tt>GET</tt></b> or <b><tt>HEAD</tt></b> requests. </p> </dd> </dt> <dt id="context.curl.proxy"> <span class="term"> <i><tt class="parameter">proxy</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <p class="para"> URI specifying address of proxy server. (e.g. <i>tcp://proxy.example.com:5100</i>). </p> </dd> </dt> <dt id="context.curl.max-redirects"> <span class="term"> <i><tt class="parameter">max_redirects</tt></i> <a href="language.types.integer.html" class="type integer">integer</a> </span> <dd> <p class="para"> The max number of redirects to follow. Value <i>1</i> or less means that no redirects are followed. </p> <p class="para"> Defaults to <i>20</i>. </p> </dd> </dt> <dt id="context.curl.curl-verify-ssl-host"> <span class="term"> <i><tt class="parameter">curl_verify_ssl_host</tt></i> <a href="language.types.boolean.html" class="type boolean">boolean</a> </span> <dd> <p class="para"> Verify the host. </p> <p class="para"> Defaults to <b><tt>FALSE</tt></b> </p> <blockquote><p><b class="note">Note</b>: This option is available for both the http and ftp protocol wrappers. <br /> </p></blockquote> </dd> </dt> <dt id="context.curl.curl-verify-ssl-peer"> <span class="term"> <i><tt class="parameter">curl_verify_ssl_peer</tt></i> <a href="language.types.boolean.html" class="type boolean">boolean</a> </span> <dd> <p class="para"> Require verification of SSL certificate used. </p> <p class="para"> Defaults to <b><tt>FALSE</tt></b> </p> <blockquote><p><b class="note">Note</b>: This option is available for both the http and ftp protocol wrappers. <br /> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="context.curl.example-post" name="context.curl.example-post"> <p><b>Example #1 Fetch a page and send POST data</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$postdata </span><span style="color: #007700">= </span><span style="color: #0000BB">http_build_query</span><span style="color: #007700">(<br /> array(<br /> </span><span style="color: #DD0000">'var1' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'some content'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'var2' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'doh'<br /> </span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$opts </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'http' </span><span style="color: #007700">=><br /> array(<br /> </span><span style="color: #DD0000">'method' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'POST'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'header' </span><span style="color: #007700">=> </span><span style="color: #DD0000">'Content-type: application/x-www-form-urlencoded'</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'content' </span><span style="color: #007700">=> </span><span style="color: #0000BB">$postdata<br /> </span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$context </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_create</span><span style="color: #007700">(</span><span style="color: #0000BB">$opts</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$result </span><span style="color: #007700">= </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://example.com/submit.php'</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">, </span><span style="color: #0000BB">$context</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="context.socket.html" class="xref">Socket context options</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="context.ssl.html">SSL context options</a></div> <div class="next" style="text-align: right; float: right;"><a href="context.params.html">Context parameters</a></div> <div class="up"><a href="context.html">Context options and parameters</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -