Streams stream_copy_to_stream
(PHP 5, PHP 7, PHP 8)
stream_copy_to_stream — 한 스트림에서 다른 스트림으로 데이터 복사
설명
stream_copy_to_stream( resource $from, resource $to, ?int $length = null, int $offset = 0 ): int|false
from
to to
현재 위치(또는 지정된 경우 offset
위치)에서 최대 length
바이트의 데이터를 복사합니다. length
가 null
이면 from
의 나머지 모든 내용이 복사됩니다.
매개변수
from
- 소스 스트림
to
- 대상 스트림
length
- 복사할 최대 바이트입니다. 기본적으로 남은 모든 바이트가 복사됩니다.
offset
- 데이터 복사를 시작할 오프셋
반환 값
복사된 총 바이트 수를 반환하거나 실패하면 false
를 반환합니다.
변경 로그
버전 | 설명 |
---|---|
8.0.0 | length 는 이제 nullable입니다. |
Examples
예제 #1 stream_copy_to_stream() 예제
<?php
$src = fopen('http://www.example.com', 'r');
$dest1 = fopen('first1k.txt', 'w');
$dest2 = fopen('remainder.txt', 'w');
echo stream_copy_to_stream($src, $dest1, 1024) . " bytes copied to first1k.txt\n";
echo stream_copy_to_stream($src, $dest2) . " bytes copied to remainder.txt\n";
?>
기타
- copy() - 파일 복사