Correa
asked on
reading/writing on text files
I´d like to know if it´s possible to work with TEXT FILES in PHP scripts. I need to implement a counter which must read a text file (composed by only one line, an integer number), increment this number and then rewrite this text file.
I´ve been using the following script in PERL to make this work for me: (who knows this bizarre language called PERL here? :-))
open(fha,"counter.txt");
$ct=<fha>;
close(fha);
open(fha,">counter.txt");
$ct++;
print fha,$ct;
close(fha);
- on the first three lines, the file "counter.txt" is opened for input, and the value of its first line (a number) is stored in the variable $ct
- on the following lines the file is opened for output, $ct is incremented and "counter.txt" is rewritten with the new incremented value (print fha,$ct)
so... Is it possible to substitute this script in PERL by one in PHP? Or isnt possible reading/writing text files in PHP?
thanks a lot,
Correa
I´ve been using the following script in PERL to make this work for me: (who knows this bizarre language called PERL here? :-))
open(fha,"counter.txt");
$ct=<fha>;
close(fha);
open(fha,">counter.txt");
$ct++;
print fha,$ct;
close(fha);
- on the first three lines, the file "counter.txt" is opened for input, and the value of its first line (a number) is stored in the variable $ct
- on the following lines the file is opened for output, $ct is incremented and "counter.txt" is rewritten with the new incremented value (print fha,$ct)
so... Is it possible to substitute this script in PERL by one in PHP? Or isnt possible reading/writing text files in PHP?
thanks a lot,
Correa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.php.net/manual/html/feature-fileupload.html
See if this can help
Joseph