Skip to content

Instantly share code, notes, and snippets.

@zuch zuch/hits.php
Created Aug 18, 2012

What would you like to do?
php - count hits to a page
$hit_count = @file_get_contents('count.txt'); // read the hit count from file
if ($hit_count > 1)
$init_date = @file_get_contents('init_date.txt');
@file_put_contents('init_date.txt', date('F j, Y, g:i a'));
echo $hit_count . " visits</br>";
echo "since " . $init_date;
$hit_count++; // increment the hit count by 1
@file_put_contents('count.txt', $hit_count); // store the new hit count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.