Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
programmershelp
domain names
dropshippers
 Downloads
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


A simple counter


A simple counter

This is our first counter example this is ideal if you are not to fussed about knowing about user details . The first step is to create a file to store the count in this example we called our file counter1.dat and started the count at 1000 . you could call your file something else but remember and change the script accordingly.

Here is the script for this example

<?php
//simple counter example v1.0
//open the counter file in read only mode
$counterfile = "./counter1.dat";
if(!($fp = fopen($counterfile,"r"))) die ("cannot open counter file");
//read the value stored in the file
$thecount = (int) fread($fp, 20);
//close the file
fclose($fp);
//increment the count
$thecount++;
//display the count
echo "visitor no : $thecount";
//open the file again in write mode and store
// the new count
$fp = fopen($counterfile, "w");
fwrite($fp , $thecount);
//close the file
fclose($fp);
?>

 

 

 




Books
 Sponsors
 Random Code
Display the date a page last modified(date and time)
Random passwords(randomizing)
Time based greeting(date and time)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials




beginners PHP Copyright © 2004 onwards by beginnersPHP.