It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

How to count the page has been accessed in PHP?

Moderator: Malcolm

How to count the page has been accessed in PHP?

Postby phpfans on Mon Feb 21, 2011 5:44 am

The PHP Counter that I recommend can only count the number of times the page has been accessed. It cannot count the number of unique visitors. The PHP hit counter simply updates a text file, which keeps track of the number of times the page is accessed. The PHP Script read the current the file, then adds one to the number, writes the number to the file and close the file. The script is then embedded into the html on the web page so that it is executed each time the page is accessed.
The hit counter script looks like this:
<?php
$filename = "hits.txt";
$count= file($filename);
$count[0]++;
$file = fopen ($filename, "w") or die ("Cannot find $filename");
fputs($file, "$count[0]");
fclose($file);
echo $count[0];
?>
phpfans
 
Posts: 2
Joined: Thu Dec 02, 2010 3:33 am

Re: How to count the page has been accessed in PHP?

Postby rajmv on Sun Jul 17, 2011 5:35 pm

Get a google analytics account.
Way easier than building your own.
rajmv
100+ Club
 
Posts: 103
Joined: Thu Jul 14, 2011 7:22 am


Who is online

Users browsing this forum: No registered users and 1 guest