PHP feof()函数 feof() 函数检查是否已达到“文件结束”(EOF)。此函数在发生错误或已达到文件结束时返回 true,否则返回 false。 语法 bool feof ( resource $handle )PHPCopy feof()函数对于遍历未知长度的数据非常有用。 示例 <?php file = fopen("/PhpProject/sample.txt", "r"); // Output a line of the file until the end is reached while(! feof(file)) { echo fgets(file); } fclose(file); ?>PHPCopy 输出 tutorialspoint tutorixPHPCopy