01 <html>
02 <head>
03 <title>Example</title>
04 </head>
05 <body bgcolor="#FFFFFF" text="#000000">
06 本文瀏覽次數: <script type="text/javascript" language="Javascript" src="/article_counter.php"></script>
07 </body>
08 </html>01 <?php
02 // get the current view
03 $counter = file_get_contents("article_counter.dat");
04
05 if(!isset($_COOKIE['article_read'])){
06 setcookie("article_read", 1, time()+3600);
07 $counter++;
08 $fp = fopen("article_counter.dat, "w");
09 fwrite($fp, $counter);
10 fclose($fp);
11 }
12
13 echo "document.write('" . $counter . "');";
14 ?>