php写的网页计数器代码
- <html>
- <head>
- <title>php写的网页计数器代码</title>
- <head>
- <body>
- <?php
- $countfile = "counter.txt";
-
- if (($fp = fopen($countfile, "r+")) == false) {
-
- printf ("open file %s failed!",$countfile);
- exit;
- }
- else
- {
-
- $count = fread ($fp,10);
-
- $count = $count + 1;
-
- fclose ($fp);
-
- $fp = fopen($countfile, "w+");
-
- fwrite ($fp,$count);
-
- fputs($fp,$fg);
-
-
- echo "<div align=center><font size=5>计数次数:$count</font><br>";
-
- $fp = fopen ($countfile, "r");
- $array_count = 1;
- while (! feof($fp)) {
- $current_number = fgetc($fp);
- $counter_array[$array_count] = $current_number;
- $array_elements = count ($counter_array);
- $array_count = $array_count + 1;
- }
- echo "<div align=center><font size=5>计数次数:";
- for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
- echo "<img src=countimg/".$counter_array[$array_id].".gif>";
- }
- echo "</font>";
- fclose ($fp);
-
- }
- ?>
- </body>
- </html>
|