易截截图软件、单文件、免安装、纯绿色、仅160KB

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);
?>


相关文档:

用php过滤表单提交中的危险html代码

用PHP过滤提交表单的html代码里可能有被利用引入外部危险内容的代码。例如,有些时候用户提交表单中含有html内容,但这可能造成显示页面布局混乱,需要过滤掉。
以下是程序代码:
复制代码
function uhtml($str) 

    $farr = array( 
    ......

php防止页面刷新代码

 可用于php的计数器和表单的提交,防止反复刷新。
复制代码
<?php
session_start();
$allow_sep = "30000";
if (isset($_SESSION["post_sep"]))
{
if (time() - $_SESSION["post_sep"] < $allow_sep)
{
exit("请不要反复刷新");
}
else
{
$_SESSION["post_sep"] = time();
}
}
e ......

linux下快速安装apache+php+mysql

 (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允许访 ......

php:global变量的使用

global定义一个全局变量,这个全局变量不是应用整个网站,而是应用与当前页面(包括require和include文件)文件。
$aa="test";
function test()
{
    global $aa;
    echo $aa;
}
test(); //print test
函数内定义的变量函数外可以调用,在函数外定义的的变量函数内不能使用。
gl ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号