PHP stream_copy_to stream() Function

❮ PHP Stream Reference

Example

Copy 1024 bytes of  data from one stream to another:

<?php
$src = fopen("test1.txt", "r");
$dest = fopen("test2.txt", "w");

// Copy 1024 bytes to test2.txt
echo stream_copy_to_stream($src, $dest, 1024) . " bytes copied to test2.txt";
?>


Definition and Usage

The stream_copy_to_stream() function copies data from one stream to another.

Syntax

stream_copy_to_stream(src, dest, maxlength, offset)

Parameter Values

Parameter Description
src Required. Specifies the source stream to copy data from
dest Required. Specifies the destination stream to copy data to
maxlength Optional. Specifies the maximum bytes to copy
offset Optional. Specifies the offset where to start to copy data

Technical Details

Return Value: The total number of bytes copied. FALSE on failure
PHP Version: 5.0+
PHP Changelog: PHP 5.1: Added the offset parameter

❮ PHP Stream Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.