ÔÀi£º
1.µÚһλʹÓÃÕßa¯ÀÀijҳ¡£
2.ËÅşÆ÷³Ìʽ´Ó×ÊÁÏ¿a»oµµ°¸ÖжÁÈ¡¸ÃÒ³±»a¯ÀÀ´ÎÊı¡£
3.½«´ÎÊı¼ÓÒ»´¢´ae£¬²¢½«ËuËͻصÚһλʹÓÃÕß¡£
4.µÚ¶şÎ»Ê¹ÓÃÕßa¯ÀÀijҳ¡£
5.ËÅşÆ÷³Ìʽ´Ó×ÊÁÏ¿a»oµµ°¸ÖжÁÈ¡¸ÃÒ³±»a¯ÀÀ´ÎÊı¡£
6.½«´ÎÊıÔÙ¼ÓÒ»´¢´ae£¬²¢½«ËuËͻصڶşÎ»Ê¹ÓÃÕß¡£
ĞeÒªÁ˽aµÄº¯Êı:
fopen()´o¿ªÎļş
filesize()»ñµÃÎļş´oĞ¡
fseek()Òƶ¯ÎļşÖ¸Õe
fgets()µÃµ½ÎļşÖ¸ÕeËuÔÚĞĞÄÚÈİ
fputs()½«×Ö´®Ğ´ÈçÎļşÖ¸ÕeËuÔÚλÖÃ
fclose()¹Ø±ÕÎļş
file_exists()ÅжÏÎļşÊÇ*ñ´aeÔÚ
exec()Ö´ĞĞÍa²¿³ÌĞo
×i¼oµ¥µÄ¼ÇÊıÆ÷:
function displayCounter($counterFile) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
print "ÄuÊÇµÚ "."$num"." λΪÁÄ*İ×Ó";
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
}
if (!file_exists($counterFile)) {
exec( "echo 0 > $counterFile");
}#Èç¹u¼ÇÊıÆ÷Îļş²»´aeÔÚ£¬Ğ½¨Ëu²¢ÉeÖÃÄÚÈİΪ0
displayCounter($counterFile);
?>
PHP¼ÇÊıÆ÷±È½Ï¼oµ¥°ae£º #°aeȨûÓĞÀ²£¬Õaô¼oµ¥$fp=fopen("counter.txt","r+");
flock($fp,3);
$fsize=filesize("count.txt");
$count=fgets($fp,$fsize+1);
$count++;
fseek($fp,0);
fputs($fp,$count);
fclose($fp);
echo "ÄaÊÇµÚ $count λ*ÃÎÊÕß";
?>
PHP¼ÇÊıÆ÷ͼĞΰae£º
ÖÆ×÷10¸oͼƬ£¬½«Êı×Ö´®ÓÃͼƬ×eÆğÀ´£¬ÎҾͲ»Ï¸ËµÁË
¼ÙÉeͼƬΪ0.gif ~ 9.gif
<?
....$countΪȡµÃµÄÊıÖµ
$strcount=strval($count);
$strcount=chop($strcount);
$countlen=$strlen($strcount);
$shtml="";
for ($i=0; $i<$countlen; $i++) {
$shtml.="";
}
echo $shtml;
?>
PHP¼ÇÊıÆ÷Êı¾İ¿a°ae£º
ʹÓÃSQL¼ÇÊıÆ÷£¬ÏȽ¨ºÃ±i
CREATE TABLE counter
(
counter int not null,
id ÿÿÿÿÿint not null
)
INSERT INTO counter(counter,id) VALUE(0,1)
<?
$conn=mysql_connect(..., ..., ...);
$sql="select * from counter";
$result=mysql_query($sql,$conn);
$objresult=mysql_fetch_object($result);
$count=$objresult->counter;
$count++;
$sql="update counter set counter=".$count."where id=1";
mysql_query($sql,$conn);
mysql_close($conn);
echo "ÄaÊǵÚ$countλ*ÿÍ";
?>