简单的cookie计数器实现源码

yipeiwu_com6年前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生成QRcode实例

php生成QRcode实例

本文实例讲述了php生成QRcode实例。是一个非常有用的功能。分享给大家供大家参考。具体如下: 实例演示效果如下图所示: 主要功能代码如下: <?php ini_...

php识别翻转iphone拍摄的颠倒图片

用iphone横向拍摄并上传的图片往往是向左或向右90度侧向显示的,本文介绍如何用php识别并且翻转图片到正确位置。 ps : 此方法只能判断一些手机相机拍摄的图片位置颠倒 ...

解析php中获取系统信息的方法

$root = getenv('DOCUMENT_ROOT'); ////服务器文档根目录$port = getenv('SERVER_PORT'); ////服务器端口$file =...

深入解析PHP的Yii框架中的缓存功能

数据缓存是指将一些 PHP 变量存储到缓存中,使用时再从缓存中取回。它也是更高级缓存特性的基础,例如查询缓存和内容缓存。 如下代码是一个典型的数据缓存使用模式。其中 $cache 指向缓...

PHP中的Session对象如何使用

在PHP开发中对比起Cookie,session 是存储在服务器端的会话,相对安全,并且不像 Cookie 那样有存储长度限制。下面则是对Session的介绍。 php中的Session...