Hit Counter in Codeigniter

后端 未结 2 1533
心在旅途
心在旅途 2021-01-06 20:29

I have the code below:

(Step by step)

  1. Put counter.txt in APPPATH . \'logs/counter.txt\'
  2. Make counter_helper.p
相关标签:
2条回答
  • 2021-01-06 20:59

    I got it to work fine when I loaded the helper $this->load->helper('counter');

    application > core > MY_Controller.php

    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    class MY_Controller extends CI_Controller
    {
        public $count_visitor;
    
        public function __construct()
        {
            parent::__construct();
            $this->load->helper('counter');
            $this->count_visitor = count_visitor();
        }   
    }
    
    0 讨论(0)
  • 2021-01-06 21:09

    Yes, must load the helper:

    $this->load->helper('counter');
    

    or

    config/autoload.php: $autoload['helper'] = array('counter');

    0 讨论(0)
提交回复
热议问题