Its all about Network Simulations, Internet of Things, Sensor Networks, Programming, etc

Network Simulator 2

Network Simulator 3

Post Page Advertisement [Top]

The same file (counter.txt) is used for both reading as well as writing. So each time the file should be closed before opening for the next time as read or write mode.

<?php
$filename=”counter.txt”;
$f=fopen($filename,”r”) or die(”Read Failed”);
$str=fread($f,filesize($filename));
echo “The page has been visited for $str times since 2nd June 2009″;
fclose($f);

$f=fopen($filename, “w”) or die(”Write Failed”);
$str=$str+1;
fwrite($f,$str);
fclose($f);
?>

No comments:

Post a Comment

Bottom Ad [Post Page]