stream_copy_to_stream

Copies data from one stream to another

Syntax

stream_copy_to_stream ( resource $source , resource $dest [, int $maxlength = -1 [, int $offset = 0 ]] ) : int

Parameters

source

The source stream

dest

The destination stream

maxlength

Maximum bytes to copy

offset

The offset where to start to copy data

Return

Returns the total count of bytes copied, or FALSE on failure.

Examples

source dest

<?

$source = fopen("https://osbo.com", "r");
$dest = fopen("stream_copy_to_stream.txt", "w");

    $return = stream_copy_to_stream($source, $dest);

    echo $return;

fclose($dest);
fclose($source);

?>
1995

maxlength

<?

$source = fopen("https://osbo.com", "r");
$dest = fopen("stream_copy_to_stream.txt", "w");

    $maxlength = 1024;

    $return = stream_copy_to_stream($source, $dest, $maxlength);

    echo $return;

fclose($dest);
fclose($source);

?>
1024

offset

<?

$source = fopen("https://osbo.com", "r");
$dest = fopen("stream_copy_to_stream.txt", "w");

    $maxlength = 1024;
    $offset = 0;

    $return = stream_copy_to_stream($source, $dest, $maxlength, $offset);

    echo $return;

fclose($dest);
fclose($source);

?>
1024

PHP

Home Menu