Fungsi fpassthru() PHP

definisi dan penggunaan

keluar fpassthru() fungsi semua data sisa di pointer file.

fungsi ini akan membaca pointer file yang diberikan dari posisi saat ini ke EOF dan menulis hasilnya ke area buffer output.

syarat

fpassthru(file)
parameter penerangan
file wajib. Tentukan file atau sumber daya yang hendak dibaca.

penerangan

jika terjadi kesalahan, fpassthru() mengembalikan false. Jika tidak, fpassthru() mengembalikan dari file baca dan siapkan ke output char数目.

pual file mesti wujud dan mesti menunjuk ke fopen() atau fsockopen() berjaya membuka (tetapi belum di fclose() to close the file that has been opened (

Tips and Comments

Tip:If you have already written data to the file, you must call rewind() to move the file pointer to the beginning of the file.

Tip:If you do not modify the file and do not retrieve at a specific location, but just want to download the content of the file to the output buffer, you should use readfile(), so that the fopen() call can be omitted.

Comment:When using fpassthru() for binary files on Windows systems, make sure to add b in the mode when opening the file with fopen() to open the file in binary mode. Encourage the use of the b flag when handling binary files, even if the system does not need it, as this can make the script more portable.

Example

Example 1

<?php
$file = fopen("test.txt","r");
// Read the first line
fgets($file);
// Send the rest of the file to the output cache
echo fpassthru($file);
fclose($file);
?>

Output:

There are three lines in this file.
This is the last line.59

Note:59 menunjukkan jumlah karakter yang disampaikan.

Example 2

Dump the index page of the www server:

<?php
$file = fopen("http://www.example.com","r");
fpassthru($file);
?>