How to call codeigniter controller function from view

后端 未结 14 1803
小蘑菇
小蘑菇 2020-11-27 05:53

How to call codeigniter controller function from view? When i call the function in a controller, get a 404 page.

14条回答
  •  天命终不由人
    2020-11-27 06:35

    class MY_Controller extends CI_Controller {
    
        public $CI = NULL;
    
        public function __construct() {
            parent::__construct();
            $this->CI = & get_instance();
        }
    
        public function yourMethod() {
    
        }
    
    }
    
    // in view just call
    $this->CI->yourMethod();
    

提交回复
热议问题