简单的cookie计数器实现源码

yipeiwu_com5年前PHP代码库

复制代码 代码如下:

<?php  if (!empty ($_COOKIE['example'] ))
             $example = ++$_COOKIE['example'] ;
        else $example = 1 ; 
            setcookie("example",$example,time()+54000);
?>

复制代码 代码如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>简单的COOKIE计数器</title>
<style type="text/css">
<!--
.style1 {
    font-size: 14px;
    font-family: "华文琥珀";
}
.style2 {
    font-size: 25px;
    font-family: "华文行楷";
}
.style3 {
    font-size: 13px;
    font-family: "华文琥珀";
}
-->
</style>
</head>
<body>
<table width="350" height="208" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td background="images/136.JPG">
      <table width="240" height="208" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="30" align="center" class="style2"> </td>
      </tr>
      <tr>
        <td height="25" align="center" class="style2">欢迎光临</td>
      </tr>
      <tr>
        <td height="30" align="center" valign="top">
          <span class="style1">本页已经被访问:</span>
          <span class="style2"> <?php echo "$example";?>次</span>
        </td>
      </tr>
      <tr>
        <td height="18" align="center" valign="top">
          <span class="style3">简单的COOKIE计数器</span>
        </td>
      </tr>
      <tr>
        <td height="30" align="center"> </td>
      </tr>
    </table> </td>
  </tr>
</table>
</body>
</html>


 

相关文章

php+ajax实现的点击浏览量加1

下面就分享一段相对完整的能够在实际应用中派上用场的代码,此代码是ajax结合php代码实现的。 一.ajax代码如下: <!DOCTYPE html> <html&...

php中print(),print_r(),echo()的区别详解

echo是PHP语句, print和print_r是函数,语句没有返回值,函数可以有返回值(即便没有用)   print()   &nb...

php内核解析:PHP中的哈希表

PHP中使用最为频繁的数据类型非字符串和数组莫属,PHP比较容易上手也得益于非常灵活的数组类型。 在开始详细介绍这些数据类型之前有必要介绍一下哈希表(HashTable)。 哈希表是PH...

php开启多进程的方法

本文实例讲述了php开启多进程的方法。分享给大家供大家参考。具体实现方法如下: 复制代码 代码如下: <?php  $IP='192.168.1.1';//Wi...

无需重新编译php加入ftp扩展的解决方法

首先,进入源码目录cd php-5.2.13/ext/ftp #运行phpize生成configure/usr/local/php/bin/phpize #编译,指定php-config...