从类中获取(错误)消息

If I have a model login (class Login) that when posted to from a login.php (the form) operates as any other login script. If an error occurs it dumps the error into a public function within the class.

public function displayMessageEntry($error, $exit = NULL) {

    if( !empty($error) ) :

        return $error;

    endif;

}

via $this->error ? self::displayMessageEntry($this->error, false) : self::displayMessageEntry($this->msg, false);

This works all fine when I was using simple templates as I would just echo it out and it would appear in the body portion when I had a head, body, and footer includes, however my design has gotten more complex, and I cannot seem to figure out how to access the $error data (if any), via something like this: <?php echo isset($err) ? $err : NULL; ?> called on the login page itself. Under previous login scripts I used I would just have the procedural code under an isset($_POST) and then any errors or messages would be added to an array and parsed the aforementioned way. Is there any way of doing this given the layout I mentioned?

Got it. Was as simple as <?php echo isset($login->error) ? $login->error : ''; ?> and modifying the display function to:

public function displayMessageEntry($error, $exit = NULL) {

    if( !empty($error) ) :

        $this->error;

    endif;

}