php文本图片计数器实例
- <html>
- <head>
- <title>计数器</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>计数次数www.111cn.net:";
- 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>
|