Roshan Wijesena
Roshan Wijesena

Reputation: 3136

php text file read and out put display on browser

i have txt file assume go.txt its a log file and contents adding dynamically to the file .

i want read it using php and display on browser in each minute any help

thanks in advance roshan

Upvotes: 0

Views: 9514

Answers (1)

Nick Weaver
Nick Weaver

Reputation: 47241

You could easily put a softlink on this file and put that one in your htdocs folder. Well depends on your webserver and configuration. So you don't have to use php to read it.

If you don't want that, you can make use of the php function file_get_contents(), this will just dump the file's contents to stdout.

<?php
   echo file_get_contents(filePathToLogFile);
?>

You'll have to let the client poll to update the page. This can be achieved with javascript. Something like this could do the work:

refreshPage();
setInterval("refreshPage()", 60000);
function refreshPage() {
    window.location.reload();
} 

Upvotes: 6

Related Questions