Easily track how many times a page on your website has been viewed with this Simple PHP Hit Counter. This script is incredibly lightweight and easy to set up because it does not require a database. Instead, it stores the view count in a simple text file on your server, making it perfect for small projects, landing pages, or any situation where a full analytics suite is overkill.

Features:

  • Track Page Views: Counts every time a PHP page is loaded.
  • No Database Required: Extremely easy setup, just upload the files.
  • Uses a Simple Text File: Stores the count in a single, easy-to-manage counter.txt file.
  • Lightweight and Fast: Minimal code ensures it has virtually no impact on your page load speed.
  • Easy 2-Step Integration: Simply include one PHP file and echo the variable to display the count.

Important Setup Note:

For the script to work, the counter.txt file must be writable by the web server. After uploading the files, you may need to change the file permissions of counter.txt to 664 or 775 using an FTP client or your hosting control panel's File Manager.

How to Use:

  1. Upload counter.php and counter.txt to the same folder on your server.
  2. In any PHP page where you want to track and display views, add this line of code at the very top: <?php include 'counter.php'; ?>
  3. To display the count anywhere in your HTML, simply echo the $page_views variable, like this: <?php echo $page_views; ?> views