CI (CodeIgniter) is an original method for calculating the number of visitors, cicodeigniter. CI (CodeIgniter) is an original method to calculate the number of visitors. cicodeigniter this article describes how to calculate the number of visitors by using CI (CodeIgniter. I will share it with you for your reference. CI (CodeIgniter) is an original method for calculating the number of visitors. cicodeigniter
This example describes how to calculate the number of visitors by using CI (CodeIgniter. We will share this with you for your reference. The details are as follows:
If you don't talk nonsense, go to the Code First:
Controller file:
/Application/controllers/hello. php is as follows:
<? 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) {// access path: http: // localhost/ci/index. php/hello/showval/Tom $ this-> name = $ name; @ $ num = file_get_contents ('. /num.txt '); // add the @ blocking warning prompt (if no TXT file is run for the first time, a warning prompt will be displayed.) $ 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 _ view ', $ arr );}}
View File:
/Application/views/test_views.php:
Access Statistics<? Php echo $ v_name;?> Yes <? Php echo $ v_num;?> Visitor
Shows the running result: