PHP简单计数器
<?php
/*使用文本文件记录数据的简单实现*/
$counter=1;
if(file_exists("mycounter.txt")){
$fp=fopen("mycounter.txt","r");
$counter=fgets($fp,9);
$counter++;
fclose($fp);
}
$fp=fopen("mycounter.txt","w");
fputs($fp,$counter);
fclose($fp);
echo "<h1>您是第".$counter."次访问本页面!<h1>";
?>
<?php
//下面这个为使用基于数据库的简单计数器,未添加其他防止一人重复刷新的方法。仅供参考。。
$conn=mysql_connect("localhost","root","abc");
$result=mysql_query("use db_counter");
$re=mysql_query("select * from tb_counter");
$result=mysql_fetch_row($re);
$counter=$result[0];
echo "您是第{$counter}位访问者!";
$counter+=1;echo "<hr>{$counter}";
mysql_query("update tb_counter set counter=$counter");
mysql_close($conn);
?>
相关文档:
1查找字符位置函数:
strpos($str,search,[int]):查找search在$str中的第一次位置从int开始;
stripos($str,search,[int]):函数返回字符串在另一个字符串中第一次出现的位置。该函数对大小写不敏感
strrpos($str,search,[int]):查找search在$str中的最后一次出现的位置从int
2、提取子字符函数(双字节)
subm ......
void header ( string string [, bool replace [, int http_response_code]] )
void header ( string string [, bool replace [, int http_response_code]] )
header()是用来发送 HTTP Header的。replace是个可选的参数,指示是否替代一个先期相似的header,
......
今天是一个值得纪念的日子,终于把别的事情都干掉了,可以一心一意的学习我最爱的PHP了,小欢呼一下.耶~~
首先.结合自己的思考,有了几个关于1+1=2的表示方法,具体罗列如下:
首先是一种很简单的表示方法:
<?php
$a =1+1;
echo "1+1=".$a;
?>
//这种方法用的并不多,只是为了加深对变量 ......
(1)、yum安装mysql
//yum安装
yum -y install mysql mysql_server
//在服务清单中添加mysql服务
chkconfig --add mysqld
//服务启动
service mysqld start
//初始化mysql数据库
/usr/bin/mysql_secure_installation
(2)、安装apache
yum -y install httpd
service httpd start
添加iptables允许访 ......