| px | top | add code | search | signup | login | help |
/* dcounter.php3 */
<?php
/* Embedded page-hit counter for PHP 3
D. Shahbaz, copyright 1998
dshahbaz@ucla.edu
*/
function UpdateHitCount($filename){
global $pageHitCount;
$pageHitCount += 1;
$fp = fopen($filename,"r+");
fwrite($fp, "<? \$pageHitCount = $pageHitCount // <- Don't touch ?> ", 58);
fclose($fp);
}
?>
/* mypage.php3 */
<? $pageHitCount = 19 // <- Don't touch ?>
<?php include "dcounter.php3" ?>
/* The above two lines should be the first lines of your script. */
/* The following lines can be anywhere you want the hits to be shown. */
<?php
UpdateHitCount("mypage.php3"); /*maybe UpdateHitCount($PHP_SELF) will work?*/
echo "Hits on this cool page: $pageHitCount";
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.