php単純カウンタ


詳細

";

//2-------     
$file="../counter/count.dat";
if (!file_exists($file)) {
	$num_txt=1;
}else {
	$num_txt=file_get_contents($file);
	$num_txt++;
}
$fp=fopen($file, "w");
fwrite($fp, $num_txt);
fclose($fp);
echo "You are the ".$num_txt." times visit."."";

//3-------      
$file = "../counter/count.dat";
if (! file_exists ( $file )) {
	$fp = fopen ( $file, "w" );
	fwrite ( $fp, "0" );
	fclose ( $fp );
}
$num_txt = file_get_contents ( $file );
session_get_cookie_params ( 24 * 3600 );
session_start ();
if (! isset ( $_SESSION ["visited"] )) {
	$num_txt ++;
	$fp = fopen ( $file, "w" );
	fwrite ( $fp, $num_txt );
	fclose ( $fp );
	$_SESSION ["visited"] = "true";
}
echo "You are the " . $num_txt . " times visit." . "";

//4--------     ,  ,    0-9       
//5---------      ,      
?>