Your showHitCounter function prints a div but nothing in the div.
The function never counts the amount of lines in the file and never prints this, so that you see nothing is normal.
Your hit function has the variable $T which is never used and you check a hit with a cookie, which will never be the nice way for a hitcounter.
Why is a cookie bad ? Because a user can simply unset the cookie and visit again.
There are loads of hitcounters on the web that you can use, if your really want to code one yourself, then I suggest you first choose what you want to count.
Every page view ?
Every unique page view ?
A user can view a page once per day ?
If you simply want every page view, then you can simply save the number of hits and add 1 to it every view.
For every unique page view, you will have to save the IP off a viewer and you can select all lines from a file to count the amount of unique views.
And if you want a user to view a page once every x hours or days, you will have to save the IP with the Date of the view and check if the date is before the x hours or days.
according to php tutorials you can create a counter text file of the name hitcounter.txt and save it to the same directory you will put your hit counter in.
Open your php editor. Save the document as counter.php. Set your opening statement for PHP script.
Set the variable for the file named hitcounter.txt and place this between your PHP tags. remember to place the filename in quotes. place the semicolon on the end of the line to end the command.
$count_my_page = ("hitcounter.txt");
Set the number of visits to the current value of the contents of the hitcounter.txt file:
When the script is accessed as the page loads, it not only reads the current number of hits on the page in the hitcounter.txt, it must increase the value by 1 for the current hit to be recorded. Add 1 to your value of $hits and call it $hits.