アクセスカウンター
<html>
<head>
<title>アクセスカウンター</title>
</head>
<body>
<center>
<?php
if($file = fopen("./dat/count.dat", "r+")) { // ファイルを開く
flock($file, LOCK_EX); // ファイルロック
$count = fgets($file); // カウント読み込み
echo "あなたは " . ++$count . " 人目の訪問者です"; // カウント+1 表示
rewind($file); // ポインタを先頭に
fputs($file, $count); // ファイル書き込み
flock($file, LOCK_UN); // ファイルロック解除
fclose($file); // ファイルを閉じる
}
?>
</center>
</body>
</html>
〔 実行する 〕