如何从codeigniter中的控制器调用视图中的函数?

时间:2016-09-21 10:28:09

标签: php codeigniter model-view-controller

我想将函数randstring调用到视图输入中。如果有人知道,请帮助别人。

class Quote extends CI_Controller {
    public function __construct() {        
        parent::__construct();
        $this->load->model('model_quote');
    } 
    public function randstring(){
        $characters = '0123456789';
        $randomString = 'Q';
        for ($i = 0; $i < 5; $i++) {$randomString .= $characters[rand(0, strlen($characters) - 1)];}
        $random = $randomString;
        $r = $this->db->get_where('quotation_parent',array('qoute_no'=>$random))->row_array();
        if(!empty($r)){
            $this->randstring();
        }else{
            return $r['qoute_no'];  
        }
    } 
}

0 个答案:

没有答案