防刷新的php文本计数器

<?php 

$file   =   "counter.txt "; 
//File   name 

//That 's   it 

if(   !   file_exists(   "$file "   )   )   { 
touch(   "$file "   ); 
chmod( "$file ",0777); 
$fp=fopen( "$file ", "r+ "); 
fseek($fp,0); 
$compteur   =   0; 
fputs($fp,$compteur); 


if(   is_readable(   "$file ")   and   is_writable(   "$file ")   )   { 

$fp=fopen( "$file ", "r+ "); 
$compteur=fgets($fp,9999); 
fseek($fp,0); 
$compteur++; 
fputs($fp,$compteur); 
fclose($fp); 
print   $compteur; 
}   else   { 
chmod( "$file ",0777); 


?>
发布了4 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/HughNian/article/details/7051184