本文實(shí)例講述了PHP簡單實(shí)現(xiàn)文本計數(shù)器的方法。分享給大家供大家參考,具體如下:
<?php
if (file_exists('count_file.txt'))
{
$fil = fopen('count_file.txt', r);
$dat = fread($fil, filesize('count_file.txt'));
echo $dat+1;
fclose($fil);
$fil = fopen('count_file.txt', w);
fwrite($fil, $dat+1);
}
else
{
$fil = fopen('count_file.txt', w);
fwrite($fil, 1);
echo '1';
fclose($fil);
}
?>
希望本文所述對大家PHP程序設(shè)計有所幫助。