uTools-Manuals/docs/php/stream_copy_to_stream.html
2019-04-08 23:22:26 +08:00

157 lines
6.2 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>Copies data from one stream to another</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.stream-copy-to-stream" class="refentry">
<div class="refnamediv">
<h1 class="refname">stream_copy_to_stream</h1>
<p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">stream_copy_to_stream</span> &mdash; <span class="dc-title">Copies data from one stream to another</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.stream-copy-to-stream-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>stream_copy_to_stream</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$source</code></span>
, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$dest</code></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$maxlength</code><span class="initializer"> = -1</span></span>
[, <span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code><span class="initializer"> = 0</span></span>
]] ) : <span class="type">int</span></div>
<p class="para rdfs-comment">
Makes a copy of up to <code class="parameter">maxlength</code> bytes
of data from the current position (or from the
<code class="parameter">offset</code> position, if specified) in
<code class="parameter">source</code> to <code class="parameter">dest</code>. If
<code class="parameter">maxlength</code> is not specified, all remaining content in
<code class="parameter">source</code> will be copied.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.stream-copy-to-stream-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">source</code></dt>
<dd>
<p class="para">
The source stream
</p>
</dd>
<dt>
<code class="parameter">dest</code></dt>
<dd>
<p class="para">
The destination stream
</p>
</dd>
<dt>
<code class="parameter">maxlength</code></dt>
<dd>
<p class="para">
Maximum bytes to copy
</p>
</dd>
<dt>
<code class="parameter">offset</code></dt>
<dd>
<p class="para">
The offset where to start to copy data
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.stream-copy-to-stream-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns the total count of bytes copied, 或者在失败时返回 <strong><code>FALSE</code></strong>.
</p>
</div>
<div class="refsect1 changelog" id="refsect1-function.stream-copy-to-stream-changelog">
<h3 class="title">更新日志</h3>
<p class="para">
<table class="doctable informaltable">
<thead>
<tr>
<th>版本</th>
<th>说明</th>
</tr>
</thead>
<tbody class="tbody">
<tr>
<td>5.1.0</td>
<td>
Added the <code class="parameter">offset</code> parameter
</td>
</tr>
</tbody>
</table>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.stream-copy-to-stream-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-4818">
<p><strong>Example #1 A <span class="function"><strong>stream_copy_to_stream()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$src&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.example.com'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dest1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'first1k.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'w'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$dest2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'remainder.txt'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'w'</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">stream_copy_to_stream</span><span style="color: #007700">(</span><span style="color: #0000BB">$src</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dest1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1024</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;bytes&nbsp;copied&nbsp;to&nbsp;first1k.txt\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">stream_copy_to_stream</span><span style="color: #007700">(</span><span style="color: #0000BB">$src</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$dest2</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"&nbsp;bytes&nbsp;copied&nbsp;to&nbsp;remainder.txt\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.stream-copy-to-stream-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="copy.html" class="function" rel="rdfs-seeAlso">copy()</a> - 拷贝文件</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>