PHP readfile() function is used to read a file and to write it to the output buffer. In case of a successful interaction, PHP readfile() function returns the number of bytes of the file read, while in case of a failure, a FALSE or an error is returned.

Syntax:

Filename:  This is a mandatory parameter which specifies the name of the file to read.

Include_path: This is an optional parameter which is used to search a file in the included path, if the value of this parameter is set to “1” or “TRUE”. The default value of include-path is FALSE.

Context: This is an optional parameter which specifies the context (a set of options which is used to modify the behavior of a stream) of the file handle. In other words this parameter is a context stream resource.

<!DOCTYPE html> <html> <body>   <?php echo readfile("phpfile.txt"); ?>   </body> </html>
Hello!I am the first line. And I am the second line. Hey, I am the third one.