php图片统计器
这个网页图片统计器的原理很简单就是把我们保存到txt中的文本读出来再做成相对就的图片数字,这样就可以做成网页图片统计器了,php实例代码如下:
- <HTML>
- <HEAD>
- <TITLE>图形页面计数器范例</TITLE>
- </HEAD>
- <BODY>
- <?PHP
- $countfile = "num.txt";
-
- if (($fp = fopen($countfile, "r+")) == false) {
- printf ("打开文件 %s 失败!",$countfile);
- exit;
- }
- else
- {
-
- $count = fread ($fp,10);
-
- $count = $count + 1;
-
- fclose ($fp);
-
- $fp = fopen($countfile, "w+");
-
- fwrite ($fp,$count);
-
- fclose ($fp);
-
- }
-
-
-
- $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 ("<table border="0" height="5" align="left"><tr><td align="center">欢迎您,第");
-
- for ($array_id = 1;$array_id < $array_elements; ++ $array_id) {
- echo ("<img src="./img/$counter_array[$array_id].gif" align=absmiddle>");
- }
-
- echo ("位客人</td></tr></table>");
- ?>
- </BODY>
- </HTML>