Welcome to WebmasterWorld Guest from 18.104.22.168 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
PHP and Counters circuitjump
How do I make a counter in PHP?
I've tried it this way;
$counter = 0; $counter = ++$counter; print $counter." line<br>";
And it does not work.
Anyone got any ideas?
That looks like it should increment. As long as you don't reset $counter to 0 on each call.
How are you saving the variable $counter?
actually, that was my problem.
I was reseting it back to zero. Since I had it in a loop I was'nt paying attention to how it was working.
Thanks for the help
Give this php a whirl: /* just make up a file called counter.txt with one line - "0" (no double quotes) */ <? $counter = file("counter.txt"); echo ("You are visitor number $counter!\n"); $newcount = ++$counter; // update counter.txt $file = fopen("counter.txt","w"); fwrite($file,"$newcount"); fclose($file); ?>