PHP: Hypertext Preprocessor This little PHP code snippet could come in handy for those in a need to display most recent entries in a considerably heavy text file, e.g. Apache log.

tail in nix

In UNIX and UNIX-like environments there’s a command called tail1, that does the trick of displaying last few lines in a text file, e.g.

$ tail -n 10 /home/clients/tekkie.dev/logs/default-error.log

for the last 10 lines of Apache error log. On the remote server this kind of tool is the subject of SSH access or the possibility of using proc_open or exec functions of PHP to call tail. Mostly, esp. on the virtual servers, this is not the case.

tail in PHP

The above reasoning is exactly why this tail PHP code is a handy tool:

Download php tail