stream_copy_to_stream
(PHP 5, PHP 7)
stream_copy_to_stream - 将数据从一个流复制到另一个流
描述
int stream_copy_to_stream ( resource $source , resource $dest [, int $maxlength = -1 [, int $offset = 0 ]] )
使得最多的副本maxlength
从当前位置(或从数据的字节offset
位置上,如果指定)在source
到dest
。如果maxlength
未指定,则所有剩余的内容source
将被复制。
参数
source
源流
dest
目标流
maxlength
最大字节复制
offset
从哪里开始复制数据的偏移量
返回值
返回复制的字节总数,或失败时返回FALSE
。
Changelog
版本 | 描述 |
---|---|
5.1.0 | 添加了偏移量参数 |
示例
示例#1 stream_copy_to_stream()示例
<?php
$src?=?fopen('http://www.example.com',?'r');
$dest1?=?fopen('first1k.txt',?'w');
$dest2?=?fopen('remainder.txt',?'w');
echo?stream_copy_to_stream($src,?$dest1,?1024)?.?"?bytes?copied?to?first1k.txt\n";
echo?stream_copy_to_stream($src,?$dest2)?.?"?bytes?copied?to?remainder.txt\n";
?>
另请参阅
- copy() - 复制文件
← stream_context_set_params
stream_encoding →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com