Я пытаюсь написать класс, который отображает ошибки. Я хотел бы иметь возможность сделать это на одной линии. Так это то, что я использую, чтобы отобразить сообщение об ошибке:Почему мой метод не работает?
$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?
http://en.wikipedia.org/wiki/Fluent_interface#PHP – Phil