Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION external text file
#3
A complete example would be...




PHP Code:
<?php


  $filename 
"test.dat";
  
  
while (1) {
    $filecontents read_file($filename);
    $content htmlspecialchars($filecontentsENT_COMPAT'utf-8'false);
    echo $content;   
    flush
();
    ob_flush();    
    sleep
(60);  // read temperature every 60 seconds
  }

  /* +-------------------------------------------------------+
     |                  read file - function                 |
     |  file can be any qualified path including web urls.   |
     |  $filename = "http://www.example.com/some/file.txt"   |
     +-------------------------------------------------------+ */
    
  
function read_file($filename) {
    if (file_exists($filename)) {
      $filedata file_get_contents($filename);
      return $filedata;
    } else {
      echo "File not found";
    }
  }

?>
Thanks,
jwzumwalt
(\__/)
(='.'=)
(")_(")
Reply


Messages In This Thread
external text file - by bmdt - 2016-05-06, 17:56:00
RE: external text file - by Bigin - 2016-05-06, 18:31:33
RE: external text file - by jwzumwalt - 2016-05-07, 01:37:47
RE: external text file - by Bigin - 2016-05-07, 03:12:01
RE: external text file - by jwzumwalt - 2016-05-08, 00:47:33
RE: external text file - by shawn_a - 2016-05-07, 04:25:25
RE: external text file - by shawn_a - 2016-05-08, 00:55:16



Users browsing this thread: 1 Guest(s)