mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 05:26:57 +08:00
98 lines
5.6 KiB
HTML
98 lines
5.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<title>Set the default stream context</title>
|
|
</head>
|
|
<body class="docs"><div id="layout">
|
|
<div id="layout-content"><div id="function.stream-context-set-default" class="refentry">
|
|
<div class="refnamediv">
|
|
<h1 class="refname">stream_context_set_default</h1>
|
|
<p class="verinfo">(PHP 5 >= 5.3.0, PHP 7)</p><p class="refpurpose"><span class="refname">stream_context_set_default</span> — <span class="dc-title">Set the default stream context</span></p>
|
|
|
|
</div>
|
|
|
|
<div class="refsect1 description" id="refsect1-function.stream-context-set-default-description">
|
|
<h3 class="title">说明</h3>
|
|
<div class="methodsynopsis dc-description">
|
|
<span class="methodname"><strong>stream_context_set_default</strong></span>
|
|
( <span class="methodparam"><span class="type">array</span> <code class="parameter">$options</code></span>
|
|
) : <span class="type">resource</span></div>
|
|
|
|
<p class="simpara">
|
|
Set the default stream context which will be used whenever file operations
|
|
(<span class="function"><a href="fopen.html" class="function">fopen()</a></span>, <span class="function"><a href="file_get_contents.html" class="function">file_get_contents()</a></span>, etc...)
|
|
are called without a context parameter. Uses the same syntax as
|
|
<span class="function"><a href="stream_context_create.html" class="function">stream_context_create()</a></span>.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 parameters" id="refsect1-function.stream-context-set-default-parameters">
|
|
<h3 class="title">参数</h3>
|
|
<p class="para">
|
|
<dl>
|
|
|
|
|
|
<dt>
|
|
<code class="parameter">options</code></dt>
|
|
|
|
<dd>
|
|
|
|
<p class="para">
|
|
The options to set for the default context.
|
|
</p>
|
|
<blockquote class="note"><p><strong class="note">Note</strong>:
|
|
<p class="para">
|
|
<code class="parameter">options</code> must be an associative
|
|
array of associative arrays in the format
|
|
<em>$arr['wrapper']['option'] = $value</em>.
|
|
</p>
|
|
</p></blockquote>
|
|
</dd>
|
|
|
|
|
|
</dl>
|
|
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 returnvalues" id="refsect1-function.stream-context-set-default-returnvalues">
|
|
<h3 class="title">返回值</h3>
|
|
<p class="para">
|
|
Returns the default stream context.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 examples" id="refsect1-function.stream-context-set-default-examples">
|
|
<h3 class="title">范例</h3>
|
|
<p class="para">
|
|
<div class="example" id="example-4817">
|
|
<p><strong>Example #1 <span class="function"><strong>stream_context_set_default()</strong></span> example</strong></p>
|
|
<div class="example-contents">
|
|
<div class="phpcode"><pre><span style="color: #000000">
|
|
<span style="color: #0000BB"><?php<br />$default_opts </span><span style="color: #007700">= array(<br /> </span><span style="color: #DD0000">'http'</span><span style="color: #007700">=>array(<br /> </span><span style="color: #DD0000">'method'</span><span style="color: #007700">=></span><span style="color: #DD0000">"GET"</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'header'</span><span style="color: #007700">=></span><span style="color: #DD0000">"Accept-language: en\r\n" </span><span style="color: #007700">.<br /> </span><span style="color: #DD0000">"Cookie: foo=bar"</span><span style="color: #007700">,<br /> </span><span style="color: #DD0000">'proxy'</span><span style="color: #007700">=></span><span style="color: #DD0000">"tcp://10.54.1.39:8000"<br /> </span><span style="color: #007700">)<br />);<br /><br /></span><span style="color: #0000BB">$default </span><span style="color: #007700">= </span><span style="color: #0000BB">stream_context_set_default</span><span style="color: #007700">(</span><span style="color: #0000BB">$default_opts</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* Sends a regular GET request to proxy server at 10.54.1.39<br /> * For www.example.com using context options specified in $default_opts<br /> */<br /></span><span style="color: #0000BB">readfile</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.com'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span>
|
|
</span>
|
|
</pre></div>
|
|
</div>
|
|
|
|
</div>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div class="refsect1 seealso" id="refsect1-function.stream-context-set-default-seealso">
|
|
<h3 class="title">参见</h3>
|
|
<p class="para">
|
|
<ul class="simplelist">
|
|
<li class="member"><span class="function"><a href="stream_context_create.html" class="function" rel="rdfs-seeAlso">stream_context_create()</a> - 创建资源流上下文</span></li>
|
|
<li class="member"><span class="function"><a href="stream_context_get_default.html" class="function" rel="rdfs-seeAlso">stream_context_get_default()</a> - Retrieve the default stream context</span></li>
|
|
<li class="member">Listing of supported wrappers with context options (<a href="wrappers.html" class="xref">支持的协议和封装协议</a>).</li>
|
|
</ul>
|
|
</p>
|
|
</div>
|
|
|
|
|
|
</div></div></div></body></html> |