HomeMenu
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 $from,
    resource $to,
    ?int $length = null,
    int $offset = 0
): int|false

Parameters

from

The source stream.

dest

The destination stream.

length

Maximum bytes to copy. By default all bytes left are copied.

offset

The offset where to start to copy data.

Return

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

Examples

1 · from to

<?

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

    $return = stream_copy_to_stream($from, $to);

    echo $return;

fclose($to);
fclose($from);
1995

2 · length

<?

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

    $length = 1024;

    $return = stream_copy_to_stream($from, $to, $length);

    echo $return;

fclose($to);
fclose($from);
true

3 · offset

<?

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

    $length = 1024;
    $offset = 0;

    $return = stream_copy_to_stream($from, $to, $length, $offset);

    echo $return;

fclose($to);
fclose($from);
1024