• PHP Video Tutorials

PHP - Function readfile()



The readfile() function can read a file and write it to the output buffer. This function can return the number of bytes read on success, or false and an error on failure. We can hide the error output by adding an '@' in front of 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. We can use the URL as a filename with this function if the fopen() function wrappers have enabled in php.ini file.

Example

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

Output

Tutorialspoint
Tutorix
23
php_function_reference.htm
Advertisements