fgets() function reads the data and returns a line from an open file. It begins to read from beginning and stop returning on a new line or on the specified length whichever comes first. By default it reads the first 1 kilo bytes, but it can be set lesser or larger. If this function is used in one file that has no line breaks, it returns False.
File is essential for running this function. The file must also be opened.
Length is optional. Setting the length at specifies number of bytes will increase or decrease the file compilation.
$file = fopen("upload.php", "r") or exit("Unable to open file!");
echo fgets($file). "<br />";
In this example, the output will either print the line or return False.