PHPBuilder - Simplest Page Counter Available



RSS Twitter
Snippets Other

Simplest Page Counter Available

by: Simon Rundell
|
September 10, 2002

Version: 1

Type: Function

Category: Other

License: GNU General Public License

Description: Raw but functional, reads in a text file, increments, writes it out and displays the output



// The file must have global write permisions on it (chmod 666 filename)
// note absolute path is specified so that it can be used in subdirs also

$counterval = 0;
$fp = fopen( "/<absolute_path_here>/page_counter.txt","r");
$counterval = fread($fp, 26 );
fclose( $fp );
$counterval = (integer)$counterval + 1;
$fp = fopen( "/<absolute_path_here>/page_counter.txt","w+");
fwrite( $fp, $counterval, 26);
fclose( $fp );
echo "$counterval";

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Simon Rundell

Comment:



Comment:

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