Skip to content

Instantly share code, notes, and snippets.

@iGlitch
Last active August 29, 2015 14:15
Show Gist options
  • Save iGlitch/4c58f9fbf80540dde9fb to your computer and use it in GitHub Desktop.
Save iGlitch/4c58f9fbf80540dde9fb to your computer and use it in GitHub Desktop.
Simple Counter :: 1335 人目のアクセスです Format
<? /*シンプルカウンタ*/
/*count.txtを作成します*/
$fp = @fopen("count.txt","r+") or die("ファイルが開けません");
flock($fp, LOCK_EX);
$count = fgets($fp, 64); //64バイトorEOFまで取得、カウントアップ
$count++;
rewind($fp); //ポインタを先頭に、ロックして書き込み
fputs($fp, $count);
fclose($fp); //ファイルを閉じる
echo $count; //カウンタ表示
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment