Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

stream_copy_to_stream

Description

The stream_copy_to_stream of Stream for PHP 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

1 · 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

2 · 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

3 · 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
HomeMenu