Skip to content
Home » Php Programs » Read File Using Function in PHP

Read File Using Function in PHP

Program to read file using function in php. In this program we can print the read file in php program using read file. Using this program we can read the function in php programming.

Fread Definition in PHP

The fread() function in PHP is a built-in function that reads up to length bytes from an open file’s file pointer referenced by file. The fread() function terminates when it reaches the end of the file or the length supplied as a parameter, whichever comes first.

Readfile in PHP

The readfile() method is a built-in PHP function that reads a file and writes it to the output buffer. The readfile() function takes the filename as a parameter and returns the number of bytes read if it succeeds, or FALSE with an error if it fails. Here we have executed the read file using function in php for beginners.

Echo in PHP

The echo command in PHP can be used to output a string, several lines of text, escaping characters, variables, arrays, and more. echo is a statement that displays the output of a command. echo() and echo can be used with or without parentheses. echo does not produce a result. 

Read File Using Function in PHP


echo readfile("inlarn.txt");