本节内容:
php读取大文件内容
例子:
 
<?php
/*
* 读取大文件最后几行数据
* by www.jb200.com
*/
$file = $handledir.'/venocap.1';  
    $fp = fopen($file, "r");   
    $line = 100;  
    $pos = -2;  
    $t = " ";  
    $data = "";  
    while ($line > 0) {  
        while ($t != "n") {  
            $flag=fseek($fp, $pos, SEEK_END);  
            if (fseek($fp, $pos, SEEK_END)==-1){  
                //fseek($fp, 0);  
                rewind($fp);  
                $t="n";  
                $line=0;  
            }else{  
                $t = fgetc($fp);  
                $pos --;  
            }  
        }  
        $t = " ";  
        $line --;  
    }  
    while (!feof($fp)) {  
        $data .= fgets($fp);  
        $data.='<br/>';  
    }  
    fclose ($fp);  
    echo $data