Home >Backend Development >PHP Tutorial >PHP Counter_PHP Tutorial
$counterFile = "balong.txt";//The file name and path to store the value
function displayCounter($counterFile) {
$fp = fopen($counterFile,"rw");
$num = fgets($fp,5);
$num += 1;
print "You are the "."$num"." The guy looking at the counterFile";
exec( "rm -rf $counterFile");
exec( "echo $num > $counterFile");
}
if ( !file_exists($counterFile)) {
exec( "echo 0 > $counterFile");
}
displayCounter($counterFile);
?>