首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

stream_copy_to_stream

(PHP 5, PHP 7)

stream_copy_to_stream - 将数据从一个流复制到另一个流

描述

代码语言:javascript
复制
int stream_copy_to_stream ( resource $source , resource $dest [, int $maxlength = -1 [, int $offset = 0 ]] )

使得最多的副本maxlength从当前位置(或从数据的字节offset位置上,如果指定)在sourcedest。如果maxlength未指定,则所有剩余的内容source将被复制。

参数

source

源流

dest

目标流

maxlength

最大字节复制

offset

从哪里开始复制数据的偏移量

返回值

返回复制的字节总数,或失败时返回FALSE

Changelog

版本

描述

5.1.0

添加了偏移量参数

示例

示例#1 stream_copy_to_stream()示例

代码语言:javascript
复制
<?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 →

扫码关注腾讯云开发者

领取腾讯云代金券