Nina Ametuar Posts: 134
| 1) save the code as counter.php 2) create a file called counter.dat (cmod 777) 3) and include counter.php in your webpage!
Code: | <?php $COUNT_FILE = "counter.dat"; if(file_exists($COUNT_FILE)){ $fp = fopen("$COUNT_FILE", "r+"); flock($fp, 1); $count = fgets($fp, 4096); $count += 1; fseek($fp, 0); fputs($fp, $count); flock($fp, 3); fclose($fp); }else{ echo"Can't find file, check '\$file'<br>"; } ?> |
|