English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and Example of PHP readfile() Function

PHP Filesystem Reference Manual

The readfile() function can read a file and write it to the output buffer. If successful, this function can return the number of bytes read; if failed, it returns false and an error. We can hide the error output by adding a "@" symbol before the function name.

Syntax

int readfile ( string $filename [, bool $use_include_path = FALSE [, resource $context ]] )

This function can read a file and write it to the output buffer. If the fopen() function wrapper is enabled in the php.ini file, the URL of this function can be used as the filename.

Online Example

<?php
   echo readfile("/PhpProject/sample.txt");
?>

Output Result

w3codebox
Tutorix
23
PHP Filesystem Reference Manual