Best Practice to return user information
<p>Best Practice to return user information</p>

<p>Every time it bothers me; how to return information (login success, article updated)back to the user especially in OOP.. (PHP)</p>

<ul>
<li>throw new exception with multiple catch and try blocks (after catch it will stop the execution of the catch block) </li>
<li>just a bunch return values (just looks awful) </li>
<li>true and false (then in the script where you run the class check for true and false?)</li>
<li>separated class to handle the error messages  (extends Exceptions?)</li>
</ul>

<p>Any tips would be appreciated! </p>

<p>-- Update / not axpecting so many answers! wow!!</p>

<p>For example user registration; I used a custom exception class. </p>

<pre><code>/*
 * custom exception class
 */
class Message extends Exception
{
    public function __construct($message, $code = true) 
    {       
        parent::__construct($message, $code);
    }

    public function information() 
    {
        return '&lt;div class="check"&gt;&lt;img src="/admin/static/images/'.($this-&gt;code == true ? 'good' : 'bad').'.gif" alt="check" class="icon" width="20px" height="20px" /&gt;' . $this-&gt;message . '&lt;/div&gt;';
    }
}
</code></pre>

<p>and in the class itself;</p>

<pre><code>    if(is_numeric($id) === false)
    {
        Throw new Message('message', false);
    }
</code></pre>
