欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CI(CodeIgniter)簡(jiǎn)單統(tǒng)計(jì)訪問(wèn)人數(shù)實(shí)現(xiàn)方法 原創(chuàng)

原創(chuàng)  更新時(shí)間:2016年01月19日 13:01:21   原創(chuàng) 投稿:shichen2014  
這篇文章主要介紹了CI(CodeIgniter)簡(jiǎn)單統(tǒng)計(jì)訪問(wèn)人數(shù)實(shí)現(xiàn)方法,這里使用TXT文本文件簡(jiǎn)單演示了CodeIgniter框架記錄訪問(wèn)人數(shù)的實(shí)現(xiàn)技巧,需要的朋友可以參考下

本文實(shí)例講述了CI(CodeIgniter)簡(jiǎn)單統(tǒng)計(jì)訪問(wèn)人數(shù)實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:

廢話不說(shuō),先上代碼:

控制器文件:

/application/controllers/hello.php 如下:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Hello extends CI_Controller {
  public function index()
  {
    echo "Hello CodeIgniter!";
  }
  public function showval($name){
    //訪問(wèn)路徑:http://localhost/ci/index.php/hello/showval/Tom
    $this->name=$name;
    @$num=file_get_contents('./num.txt');//加上@屏蔽警告提示(第一次運(yùn)行沒(méi)有TXT文件會(huì)有警告提示)
    $num=$num?$num:0;
    $num++;
    $arr=array('v_name'=>$name,'v_num'=>$num);
    $re=fopen('./num.txt','w');
    fwrite($re,$num);
    fclose($re);
    $this->load->view('test_views',$arr);
  }
}

視圖文件:

/application/views/test_views.php 如下:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>訪問(wèn)統(tǒng)計(jì)</title>
</head>
<body>
<?php echo $v_name;?>是第 <?php echo $v_num;?> 位訪問(wèn)者
</body>
</html>

運(yùn)行結(jié)果如下圖所示:

更多關(guān)于CodeIgniter框架相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《codeigniter入門教程

希望本文所述對(duì)大家基于CodeIgniter框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論