CI (CodeIgniter) is an original method to calculate the number of visitors. cicodeigniter_PHP tutorial

Source: Internet
Author: User
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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.