2016-01-03 53 views
1

我試圖調用自定義庫函數巫婆應該返回輸入值返回窗體,但我geting錯誤。 enter image description hereCodeIgniter在[庫]中調用非對象的成員函數

的Controler:

<?php 

defined('BASEPATH') OR exit('No direct script access allowed'); 

class Guest extends CI_Controller { 

public function __construct(){ 
    parent::__construct(); 
    error_reporting(E_ALL^(E_NOTICE)); 
    $this->load->helper(array('form', 'url', 'date')); 
    $this->load->library('form_validation', 'uri'); 
    $this->load->model('dayData'); 
    $this->load->library('session'); 
    $this->load->library('guest'); 
} 

public function index(){   
    $this->login(); 
} 

public function dataToView($data, $viewFile){ 
    $this->load->view('template/header'); 
    if($viewFile != ''){ 
     $this->load->view('user/' . $viewFile, $data); 
    } 
    $this->load->view('template/footer'); 
} 

public function login(){ 
    $this->dataToView($data, 'guest/login'); 
} 

public function registration(){ 
    if($this->input->post('registrationSubmit') !== null) { 

     //$this->form_validation->set_error_delimiters('<div class="alert alert-warning" role="alert">', '</div>'); 
     $this->config->load('form_validation'); 
     $this->form_validation->set_rules($this->config->item('registrationValidation')); 

     if($this->form_validation->run() == FALSE){ 
      var_dump($this->guest->registrationPost()); 
      $this->dataToView($data, 'guest/registration'); 
     } else { 
      echo "string"; 
     } 
    } else { 
     $this->dataToView($data, 'guest/registration'); 
    } 
} 

} 

庫:

<?php 

defined('BASEPATH') OR exit('No direct script access allowed'); 

class Guest { 

protected $CI; 

public function __construct(){ 
    // Assign the CodeIgniter super-object 
    $this->CI =& get_instance(); 
    //$this->CI->load->model('Guest'); 
    $this->CI->lang->load('error', 'english'); 

} 

public function registrationPost(){ 
    $result = array('name' => $this->CI->input->post('name'), 
        'nickName' => $this->CI->input->post('nickName'), 
        'email' => $this->CI->input->post('email')); 
    return $result; 
} 

} 
+0

releated http://stackoverflow.com/questions/54566/call-toa-a-member-function-on-a-non-object – Linus

回答

0

有控制器和自定義類之間的命名衝突。他們不應該有相同的名字。

相關問題