Click to See Complete Forum and Search --> : Include Page


irishbolt
03-23-2001, 10:00 AM
I need to have a web page display the contents of a text file on it. This text file will change regularly and I need it so when the webpage is refreshed the data displayed will also change to reflect the changes in the text file.
Can anyone tell me how to do this.

ame12
03-23-2001, 11:32 AM
Try,

if ($fd = fopen("filename.txt", "r")) {
$text = fgets($fd, 16384);
fclose($fd);
}
echo($text);

RW


===========================================
http://badblue.com
Small footprint P2P web server for Windows,
File-sharing, PHP, wireless apps & more
===========================================

binary_human
03-24-2001, 01:07 AM
personally i would just try
include "filename.txt"

veggie2u
03-26-2001, 12:17 AM
I love includes. It is a great way 'template' a site. PHP is one up on ASP in this regard too, in that you can do dynamic included:

$filename = "filename.txt"
include $filename

That way you set the filename from conditional statements, or pull it from the request object.

veggie2u

veggie2u
03-26-2001, 12:37 AM
Oops - include($filename)

veggie2u

irishbolt
03-26-2001, 07:23 AM
Ok it sounds like this might work but when I put it in my html file it doesn't. Do I have to install anything else on my server. What else should be around it. Should it look like:

<script>
$filename = "filename.txt"
include $filename
</script>

do you have any examples where you have used this.

Arnold