Php tutorial: Easy Step On How To Create A Simple Hit Counter for your site. - Guruscabinet : Full of Gist

Post Top Ad

Tuesday, 9 February 2016

Php tutorial: Easy Step On How To Create A Simple Hit Counter for your site.

....
.... Most webmasters and wapmasters do think creating ahit counterhas to be complex and database driven. But am going to explain how to create asimple hit counter that is accurate and easy without worry about creating a database.
How do i create a simple hit counter?
.1.Create a .txt file e.g namehitcounter.txt at the base or root folder of your site or page u wana use the counter
.2.Create another file named egcounter.php and put this lines of code.
< ?php $count_my_page = ("hitcounter.txt"); $hits=file($count_my_page); $hits[0] ++; $fp = fopen($count_my_page , "w"); fputs($fp, "$hits[0]"); fclose($fp); echo $hits[0]; ?>.
3.To display the number of hit, use php include or require function to declare it. I.e put oranywhere you want to display the counter.
Alternative Method On How to Create a Hit Counterafterstep 1, use the code, i.e
< ?php $count_my_page = ("hitcounter.txt"); $hits=file($count_my_page); $hits[0] ++; $fp = fopen($count_my_page , "w"); fputs($fp, "$hits[0]"); fclose($fp); echo $hits[0]; ?>to display the hit anywhere in your site or page without using php include or require function.
....

No comments:

Post a Comment

What do you think about the above post? Use the comment box to have your say!