Hello, Very nice cheat sheet, all the must know is there. I picked a little mistake in you file example :
//File read
$file = fopen("test.txt", "r");
//Output lines until EOF is reached
while(! feof($file)) {
$line = fgets($file);
echo $line. "<br>";
}
fclose($file);
In order to detect end of file (and have feof return true), you must read after the last char (or line) in file. So you must read before the test (to detect an empty file) and read at the end of the loop (to avoid echoing an empty line) :
//File read
$file = fopen("test.txt", "r");
//Output lines until EOF is reached
$line = fgets($file);
while(! feof($file)) {
echo $line. "<br>";
$line = fgets($file);
}
fclose($file);