Posted in PHP 12 years ago 1 min read
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$file = 'counter.txt';
if(file_exists($file)){
$file_open = fopen($file, "r");
$cek = trim(fgets($file_open, 255));
$cek++;
} else {
$cek = 1;
}
$file_open = fopen($file, "w");
fwrite($file_open, $cek);
fclose($file_open);
echo 'Anda pengunjung ke '.$cek;
?>
</body>
</html>
Semoga bermanfaat