PHP readfile() Function – file handling

PHP readfile() Function – file handling

The readfile() function reads a file and writes it to the output buffer.

Assume we have a text file called “blog.eduguru.txt”, stored on the server, that looks like this:

“Hi, This is a test file. This is created to show the example of readfile function in php.”

The PHP code to read the file and write it to the output buffer is as follows (the readfile() function returns the number of bytes read on success):

 

<?php
echo readfile(“blog.eduguru.txt”);
?>

Output:

 

“Hi, This is a test file. This is created to show the example of readfile function in php.”