Home > Backend Development > PHP Tutorial > PHP counter program_PHP tutorial

PHP counter program_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 16:07:09
Original
988 people have browsed it

1) Text counter
$countfile="/count.txt"; //Set the file to save data
if (!file_exists($countfile)){//Determine whether the file exists
exec( "echo 0 > $countfile");
}
$fp = fopen($countfile,"rw");
$length=filesize($countfile);
$num = fgets($fp,$length);
$num += 1;
exec( "rm -rf $countfile");
exec( "echo $num > $countfile") ;
print "Total visits:"."$num"."person times"; //Display the number of visits
?>
2) Graphical counter
$countfile ="/count-num.txt"; //Set the file to save data
if (!file_exists($countfile)) //Determine whether the file exists
{exec( "echo 0 > $countfile") ;}
$fp = fopen($countfile,"rw");
$length=filesize($countfile);
$num = fgets($fp,$length);
$num += 1;
exec( "rm -rf $countfile");
exec( "echo $num > $countfile");
$len_str = strlen($num);
for ($i=0;$i<$len_str;$i++){
$each_num = substr($num,$i,1);
$out_str = $out_str . "";
}
print "Total visits:"."$out_str"."Persons"; //Display the number of visits
?>


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315155.htmlTechArticle1) Text counter?php $countfile=/count.txt;//Set the file to save data if (! file_exists($countfile)){//Determine whether the file exists exec( echo 0 $countfile); } $fp = fopen($countf...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template