CI(CodeIgniter)简单统计访问人数实现方法 <font color=red&
发布时间:2020-12-12 21:18:07 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解CI(CodeIgniter)简单统计访问人数实现方法。供大家参考研究具体如下: 废话不说,先上代码: 控制器文件: /application/controllers/hello.php 如下: name=$name; @$num=file_get_contents('./num.txt');//加上@屏蔽警告提示(第一
本篇章节讲解CI(CodeIgniter)简单统计访问人数实现方法。分享给大家供大家参考,具体如下: 废话不说,先上代码: 控制器文件: /application/controllers/hello.php 如下: 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 如下: |