pulling info from a text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neobolt
Forum Newbie
Posts: 9
Joined: Wed Apr 14, 2004 7:43 pm

pulling info from a text file

Post by neobolt »

What I am trying to do:
Example:
Page1 http://www.smartmindmedia.com/jokes/index.html
has a link to
http://www.smartmindmedia.com/jokes/ind ... d=test.txt

Click the "test link"
So now your at page
http://www.smartmindmedia.com/jokes/ind ... d=test.txt
In the main section of this page where it says DISPLAY HERE
I want to have the info in the test.txt to display.

would I use
<? echo [http://www.smartmindmedia.com/jokes/"$id"] ?>

This test.txt file is in the directory:
http://www.smartmindmedia.com/jokes/

I really have no idea what I am doing as far as PHP goes, but it seems simple enough so I'm trying to figure it out.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Uhh, no. You'd have to open the file using [php_man]fopen[/php_man], and read it using [php_man]fread()[/php_man].
PHP Manual wrote:$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
Then you can echo $contents.

You can alternativly use [php_man]file_get_contents()[/php_man] to read your text file, it apparently works better.
neobolt
Forum Newbie
Posts: 9
Joined: Wed Apr 14, 2004 7:43 pm

Post by neobolt »

Thank you
I think I can figure it out from that.
Post Reply