Best php practise display errors
<p>Is there best practice about display errors in during controller action executing on view? I mean, how do you display errors when 'login was not found in database' or 'input value has incorrect format', or 'field require value'?</p>

<p>Is there array with errors or anything else? Now my code looks like:</p>

<pre><code>if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $siteName = isset($_POST['SiteName']) ? trim($_POST['SiteName']) : null;
    $siteUrl = isset($_POST['SiteUrl']) ? trim($_POST['SiteUrl']) : null;

    if(IsNullOrEmptyString($siteName) || IsNullOrEmptyString($siteUrl)) {
        exit('Site name or site url could not be empty');
    } elseif (!preg_match('/^http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$/', $siteUrl)){
        exit('Site url has wrong format');
    }

    $filters = array('SiteName' =&gt; $siteName, 'SiteUrl' =&gt; $siteUrl);
    if($sitesRepository-&gt;select($filters)) {
        exit('Site is already exist');
    }
}
</code></pre>

<p>But if i use exit, my page doesn't continue to display. </p>
