10.8.45.3.15
In the official PHP manual, the feof () function has a lot of discussions and related tests have been conducted.
<? <! DOCTYPE html>
In PHP, The feof () implementation method does not directly check the position of the file pointer relative to the file, but returns the result based on a certain identifier. This identifier is set to "False" after each fseek () operation. The identifier is set only after a file content read operation is executed.
Based on this assumption, two types of code logic can be used.
One method is to directly check the execution results of reading functions (such as fgetc () and fgets () without checking feof.
(( = ( }
This solution utilizes the PHP-criticized function return method, so you must use "=" or "! = "For detection, the Code cannot be simplified:
( = ()) {}
Another method is to read the file one time before entering the feof () loop:
= ( (!( = ( }
After testing, it seems that the previous method is more efficient.