PHP readfile() Function – file handling

5 (100%) 3 votes

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.”

 

 

 

For any query or issue, feel free to discuss on http://discuss.eduguru.in
%d bloggers like this: