We saw in the previous lesson, that if you want to read a file, you can open it and put all it's content in some variable. But in this script we will see how to get the data from the file line by line until the end of file is reached:
{
echo fgets($file) . "<br />" ;
}
?>
Why to use this script:
Let's say you have a text file with many line:
----myfile.txt------
Hello Word.
We love PHP !
Here are great tutorials
And scripts and codes !
--------------------
if you use this script
echo $contents;
So we have to use:
{
echo fgets($file) . "<br />" ;
}
?>
We love PHP !
Here are great tutorials
And scripts and codes !