Hàm stream_copy_to stream () trong PHP
Thí dụ
Sao chép 1024 byte dữ liệu từ luồng này sang luồng khác:
<?php
$src = fopen("test1.txt", "r");
$dest = fopen("test2.txt", "w");
//
Copy 1024 bytes to test2.txt
echo stream_copy_to_stream($src, $dest, 1024)
. " bytes copied to test2.txt";
?>
Định nghĩa và Cách sử dụng
Hàm stream_copy_to_stream () sao chép dữ liệu từ luồng này sang luồng khác.
Cú pháp
stream_copy_to_stream(src, dest, maxlength, offset)
Giá trị tham số
Parameter | Description |
---|---|
src | Required. Specifies the source stream to copy data from |
dest | Required. Specifies the destination stream to copy data to |
maxlength | Optional. Specifies the maximum bytes to copy |
offset | Optional. Specifies the offset where to start to copy data |
Chi tiết kỹ thuật
Giá trị trả lại: | Tổng số byte được sao chép. FALSE khi thất bại |
---|---|
Phiên bản PHP: | 5.0+ |
PHP Changelog: | PHP 5.1: Đã thêm tham số bù đắp |
❮ Tham chiếu luồng PHP