README.md

December 5, 2022 ยท View on GitHub

Text Counter

Description

This code will take a file, who has been initialized by putting 0 in the file and will increment it and display it on a page.

More Info

Just do a php include.

Make sure your counterfile is read/writeable and that you've initialized it properly.

The if statement in the code is for use with Template Driven Site, another code submission by me. It helps to reduce duplicate hits. You may remove it if you wish.

Submitted On
ByChris Flanigan
LevelBeginner
User Rating5.0 (10 globes from 2 users)
CompatibilityPHP 3.0, PHP 4.0
CategoryMiscellaneous
WorldPHP
Archive File

API Declarations

Chris Flanigan

Source Code

<?php
if ($do == "") {
	$counterFile="counter.txt";
	$fp= fopen($counterFile,r);
	$num= fgets($fp,5);
	$num +=1;
	$suc=fclose($fp);
	print "<font face=verdana,sans-serif size=1><b>$num</b></font>";
	$fp=fopen($counterFile,w);
	$suc=fputs($fp, $num);
	$suc=fclose ($fp);
} else {
	$counterFile="counter.txt";
	$fp= fopen($counterFile,r);
	$num= fgets($fp,5);
    print "<font face=verdana,sans-serif size=1><b>$num</b></font>";
	$suc=fclose ($fp);
 }
?>