Opening text files in php
Posted: Tue Feb 15, 2005 11:36 pm
I tried the fopen function and it requires a user login other than anonymous, and only through a URL to write to the file? What's up with that? not to mention the documents I've read states that it looks for php code or something .. very weird.
Anyway, all I need to do is open up some data files in ASCII text format to retrieve data and print them onto the web page from a text file that I've printed data to from another php script.
I know in perl it's just this:
There's gotta be something similar like this in php, something to open / read / and write to files on-the-fly without authorization from the user besides the user who wrote the script himself.
Anyone know what I can do here?
Thanks
Anyway, all I need to do is open up some data files in ASCII text format to retrieve data and print them onto the web page from a text file that I've printed data to from another php script.
I know in perl it's just this:
Code: Select all
# Opening / Reading the file #
open(FILE, "data.txt") or die("Error, could not open file, $!");
print <FILE>;
close(FILE);
# Opening / Creating / Overwriting A File #
open(FILE, ">data.txt") or die("Error, could not open file, $!");
print FILE "some text";
close(FILE);There's gotta be something similar like this in php, something to open / read / and write to files on-the-fly without authorization from the user besides the user who wrote the script himself.
Anyone know what I can do here?
Thanks