in ,

How to create visit counter in PHP

Advertisement

Every web master want to now and show the visit count of the website. There are many analytics tools available such as Google analytics but showing the count on the website is diferent thing. You can also use some 3rd party tools too. But to go for those tools if you can create it with simple coding.
In this tutorial, I will show you, how you can create a visit counter with PHP and a text file. You will also realise that this one is simplest way.
Create a php cage and a text file count.txt and put 0 in it.
Now put this code in php file

The php code is simple. It will open the txt file and then increment the value inside it by 1. Every time yo have a new visitor on your website, it will increment the value by one.
This script do not show anything on the webpage. You can show visit count on the webpage just by showing the content of the text file as code below

You can customize he look of the output for better look.
This code does not count unique visits.

Advertisement

Advertisement

Written by Deepanker

Deepanker Verma is the founder of Techlomedia. He is a tech blogger, developer and gadget freak.

One Comment

Leave a Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading…

How to measure PHP page load time

Free Social Media Icon Set By Elegant Themes