PHP

Hypertext Preprocessor

Access counter

Sample

155

Sample source

counter.dat ファイル


0

ac01.php ファイル


<?php
	$fp = fopen("counter.dat", "r+");
	$count = fgets($fp);
	$count++;
	fseek($fp, 0);
	fputs($fp, $count);
?>

index.php ファイル


<!DOCTYPE html>
<html lang="ja">
<head>
	<meta charset="utf-8" />
	<title>Access counter</title>
</head>

<body>
	<?php
	 require('ac01.php');
	 echo $count;
	?>
</body>
</html>