简单的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函数的实现原理及性能分析(一)

百度工程师讲PHP函数的实现原理及性能分析(一)

前言 在任何语言中,函数都是最基本的组成单元。对于php的函数,它具有哪些特点?函数调用是怎么实现的?php函数的性能如何,有什么使用建议?本文将从原理出发进行分析结合实际的性能测试尝试...

PHP5.3.1 不再支持ISAPI

要在IIS6上使用高版本PHP,必须安装fastCGI扩展,        Microsoft FastCGI Extens...

PHP实时统计中文字数和区别

1、PHP 中如何正确统计中文字数?这个是困扰我很久的问题,PHP 中有很多函数可以计算字符串的长度,比如下面的例子,分别使用了 strlen,mb_strlen,mb_str...

一些需要禁用的PHP危险函数(disable_functions)

phpinfo() 功能描述:输出 PHP 环境信息以及相关的模块、WEB 环境等信息。 危险等级:中 passthru() 功能描述:允许执行一个外部程序并回显输出,类似于 exec(...

PHP goto语句用法实例

问题 当 PHP 在执行代码过程,在某一时刻我们希望它能跳转到某一特定位置继续执行代码,该怎么做呢? 回答 在 PHP 中,我们可以使用 goto 操作符来使 PHP 代码执行器跳转到...