正常情况下,我们可以使用fseek来读取,好处就是不会一次性读取,以下代码只适合边取边处理的情况,不适合一次性读取一次性处理。
可以用以下办法生成测试文件
$file_handle = fopen("./csdn.txt", "rb+");<BR>for ($index1 = 1; $index1 <= 200<strong>*本文来@源gao@daima#com搞(%代@#码@网2</strong><pre>搞代gaodaima码
0000; $index1++) {
fwrite($file_handle, ‘http://jb51.net’.$index1.”\r”);
}
fclose($file_handle);
读取处理代码如下:
$i = 0;<BR>$now = '';<BR>while ($i >= 0) {<BR> if ($i>10) {<BR> break;<BR> }<BR> fseek($file_handle, 0, SEEK_CUR);<BR> $now = fgetc($file_handle);//可以自己写个判断false表示文件到头<BR> if ($now == "\r") {<BR> echo '找到断点';<BR> }<BR> echo $now;<BR> $i++;<BR>}<BR>fclose($file_handle);<BR>