亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

CI(CodeIgniter)簡單統(tǒng)計訪問人數(shù)實現(xiàn)方法 原創(chuàng)

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

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

廢話不說,先上代碼:

控制器文件:

/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){
    //訪問路徑:http://localhost/ci/index.php/hello/showval/Tom
    $this->name=$name;
    @$num=file_get_contents('./num.txt');//加上@屏蔽警告提示(第一次運行沒有TXT文件會有警告提示)
    $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>訪問統(tǒng)計</title>
</head>
<body>
<?php echo $v_name;?>是第 <?php echo $v_num;?> 位訪問者
</body>
</html>

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

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

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

相關(guān)文章

最新評論