Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Other Programming › PHP Programming › PHP Hit counter.

PHP Hit counter.

Posts 1–2 of 2 · Page 1 of 1
iHolyElement
iHolyElement
PHP Hit counter.
Below is a simple example of creating a visitor counter with PHP. This implementation is very small and simple but it gives you a basic structure to work off of.

Visitor Counter

Simply writes a counter to 'HitCounter', or to the filename of your choice.

Code:
class HitCounter {
  private $count;
 
  /**
   * Constructor.
   */
  public function __construct($filename = 'HitCounter') {
    $count = @file_get_contents($filename);
    $count = $count ? $count : 0;
    $fh = fopen($filename, 'w+');                
    fwrite($fh, ++$count);
    fclose($fh);
   
    $this->count = $count;   
  }
 
  /**
   * Get count.
   *    
   * @return int
   */
  public function get_count() {
    return $this->count;
  }            
 
  /**
   * Output count.
   */
  public function display_count() {
    echo 'Hits: ' . $this->get_count();
  }
}
Counter Usage

Output the counter directly to the page.

Code:
$counter = new HitCounter();
$counter->display_count();

Custom counter message.
$counter = new HitCounter();
$count = $counter->get_count();
echo 'The count is currently ' . $count;
If you liked my tutorial please say thanks, i use a more advanced one of this but this still works, if you have some trouble with it let me know and i'll fix it. -.^
#1 · 16y ago
PieEater289
PieEater289
this is cool
#2 · 11y ago
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

  • Counter Strike: SourceBy Flawless in CounterStrike (CS) 1.6 Hacks / Counter Strike: Source (CSS) Hacks
    15Last post 20y ago
  • Lookin for WOW 1 Hit kill hack anyone know how to do itBy Spiderman in General Game Hacking
    5Last post 20y ago
  • Request: Counter-Strike CD KeyGen.By The_Enigma in Hack Requests
    9Last post 20y ago
  • Making Counter Strike ClanBy quin123 in General
    30Last post 20y ago
  • Counter Strike ClanBy quin123 in General Gaming
    13Last post 20y ago

Tags for this Thread

#counter#hit#php