feof() 对未知文本长度的的数据非常有用,我以前不知道

[复制链接]
发表于 2016-10-23 12:58:54 | 显示全部楼层 |阅读模式
PHP 检查 End-Of-File - feof()

feof() 函数检查数据是否已到达 "end-of-file" (EOF)。
feof() 对于遍历未知长度的数据很有用。
下例逐行读取 "webdictionary.txt" 文件,直到 end-of-file:
实例

  1. <?php
  2. $myfile = fopen("read.txt", "r") or die("Unable to open file!");
  3. // 输出单行直到 end-of-file
  4. while(!feof($myfile)) {
  5.   echo fgets($myfile) . "<br>";
  6. }
  7. fclose($myfile);
  8. ?>
复制代码



必火网络安全培训,北京实地培训,月月有开班,零基础入门,四个月打造渗透高手。
详情请加微信:nvhack/153-2000-4362,手机微信同号。
回复

使用道具 举报

 楼主| 发表于 2016-10-23 12:59:34 | 显示全部楼层
  1. <!DOCTYPE html>
  2. <html>
  3. <body>

  4. <?php
  5. $myfile = fopen("read.txt", "r") or die("Unable to open file!");
  6. // 输出一行直到 end-of-file
  7. while(!feof($myfile)) {
  8.    echo fgets($myfile) . "<br>";
  9. }
  10. fclose($myfile);
  11. ?>

  12. </body>
  13. </html>
复制代码
必火网络安全培训,北京实地培训,月月有开班,零基础入门,四个月打造渗透高手。
详情请加微信:nvhack/153-2000-4362,手机微信同号。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|女黑客安全网 |网站地图 | 津ICP备17008032号-3

GMT+8, 2026-7-27 12:10 , Processed in 0.077618 second(s), 24 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表