<?php $file = fopen( "count.log", "r+" ); $count = fgets($file,10); $count++; rewind($file); fputs($file, $count); fclose($file); ?> <html> <head> <title>サンプルページ</title> </head> <body> <?php echo "あなたは{$count}人目のお客様です。"; ?> </body> </html> |
<?php $path = './gif/'; $fig = 5; $file = fopen( "count.log", "r+" ); flock($file, LOCK_EX); $count = fgets($file, 10); $count++; rewind($file); fputs($file, $count); fclose($file); $cnt = sprintf("%0".$fig."d", $count); $size = getimagesize($path."0.gif"); for ($i=0; $i<strlen($cnt); $i++) {$n = substr($cnt, $i, 1); echo "<IMG SRC=\"$path$n.gif\" alt=$n $size[3]>";} ?> |