PHP readfile() Fungsi
Referensi Sistem File PHPContoh
Baca file:
<?php
echo readfile("test.txt");
?>
Definisi dan Penggunaan
Fungsi readfile() membaca file dan menulisnya ke buffer output.
Tip: Anda dapat menggunakan URL sebagai nama file dengan fungsi ini jika pembungkus fopen telah diaktifkan di file php.ini.
Sintaksis
readfile(file, include_path, context)
Nilai Parameter
Parameter | Description |
---|---|
file | Required. Specifies the file to read |
include_path | Optional. Set this parameter to TRUE if you want to search for the file in the include_path (in php.ini) as well |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
Detail Teknis
Nilai Kembali: | Jumlah byte yang terbaca saat sukses, FALSE dan error saat gagal. Anda dapat menyembunyikan pesan kesalahan dengan menambahkan '@' di depan nama fungsi |
---|---|
Versi PHP: | 4.0+ |
Log Perubahan PHP: | PHP 5.0: Menambahkan dukungan konteks |
Referensi Sistem File PHP