stream_copy_to_stream

Supported Versions: PHP 5, PHP 7, PHP 8
Copies data from one stream to another
<?php stream_copy_to_stream(    resource $from,    resource $to,    ?int $length = null,    int $offset = 0): int|false
<?php         error_clear_last();

        $stream = @fopen($prefixedLocation, 'w+b');



        if ( ! ($stream && false !== stream_copy_to_stream($contents, $stream) && fclose($stream))) {

            $reason = error_get_last()['message'] ?? '';

            throw UnableToWriteFile::atLocation($prefixedLocation, $reason);

        }