您好,登錄后才能下訂單哦!
這里我以mysql查詢日志為源文件輸入,直接顯示到網頁中查看。
<?php $file = 'mysqld-slow.log'; $fp = fopen($file, "r"); $line = 5000; $pos = -2; $t = " "; $data = " "; while ($line > 0) { while ($t != "\n") { $flag = fseek($fp, $pos, SEEK_END); if (fseek($fp, $pos, SEEK_END) == -1) { 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 ?>
<?php $file = '/path/to/file'; $fp = fopen($file, "r"); $line = 2000; $pos = -2; $t = " "; $data = " "; while ($line > 0) { while ($t != "\n") { $flag = fseek($fp, $pos, SEEK_END); if (fseek($fp, $pos, SEEK_END) == -1) { 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 ?>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。