【发布时间】:2014-10-26 06:06:51
【问题描述】:
我正在尝试编写一个显示错误的类。我希望能够在一条线上完成。所以这是我用来显示错误的:
$this->error->title("Error Title")->message("This is an error message")->redirect('home')->display();
这是我的课:
<?php
class Error {
var $title;
var $message;
var $redirect;
function title($title){
$this->title = $title;
}
function message($message){
$this->message = $message;
}
function redirect($redirect){
$this->redirect = $redirect;
}
function display(){
$CI &= get_instance();
$CI->template->overall_header($this->title);
$data = array(
'error_title' => $this->title,
'error_message' => $this->message
);
if(isset($this->redirect)){
$data['redirect'] = $this->redirect;
}
$CI->load->view('error_body', $data);
}
}
这是我得到的错误:
Fatal error: Call to a member function message() on a non-object in ...\application\frontend\controllers\members\login.php on line 128
为什么我会在 message() 方法上得到错误,但在 title 方法上却没有?
【问题讨论】: