How to create visit counter in PHP

Best WordPress Hosting
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

About The Author

    ADD YOUR COMMENT

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Receive fresh web design resources and SEO tips in your email by our weekly newsletter

You have Successfully Subscribed!