PHPBuilder - Counter



RSS Twitter
Snippets Other

Counter

by: Gary Jones
|
March 21, 2004

Version: 0.3

Type: Full Script

Category: Other

License: GNU General Public License

Description: Yes theres alot, but this ones object oriented!



class counter {
	var $file = 'hits.txt'; // Rename this path/to/file to your choosing - it will store the data.
				// Best to create file first, with 777 permissions.
	function counter()
	{
		$this->readFile();
		$this->writeFile();
	}
	
	function readFile()
	{
		$hiti = fopen($this->file, "r");
		while(!feof($hiti)){
			$this->$hits .= fgets($hiti,128);
		}
		$this->$hits=1+$this->$hits;
		echo $this->$hits;
		fclose($hiti);
	}
	
	function writeFile()
	{
		$hito = fopen($this->file,"w+");
		fputs($hito,$this->$hits);
		fclose($hito);
	}
	
}
// Usage
// $count = new counter;

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Gary Jones

Comment:



Comment:

(Maximum characters: 1200). You have characters left.