RE: [PHP] Is This Code OK?
| From: | Maxim Maletsky | Date: | Mon, 23 Oct 2000 02:01:01 +0000 |
| Subject: | RE: [PHP] Is This Code OK? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-21683@lists.php.net to get a copy of this message | ||
Have no code to give you right now, but what I would use would be sessions
and MySQL database.
I think it is much more expansible, faster, reliable and more advanced this
days.
Cheers!
-----Original Message-----
From: iGuru [mailto:tabarry@email.com]
Sent: Saturday, October 21, 2000 4:55 PM
To: php-general@lists.php.net
Subject: [PHP] Is This Code OK?
Can anyone please check if the below mentioned code is correct or can be
reduced further. I am trying to make a simple page counter with this code.
Note that the data.txt file only contains the number '1' at startup.
Can you please check if the below mentioned code is correct or can be
reduced further. I am trying to make a simple page counter with this code.
Note that the data.txt file only contains the number '1' at startup.
<?php
$file_loc = "data.txt";
$oldfile = fopen($file_loc,"r");
$file_contents = fread($oldfile,filesize($file_loc));
$oldval = $file_contents;
fclose($oldfile);
$newfile = fopen($file_loc, "w+");
echo $old;
$old = fread($newfile, $newfile);
$newval=$oldval+1;
fwrite($newfile, "$newval");
fclose($newfile);
echo $newval;
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net