What are some best practices for handling server-side errors in PHP to ensure a visually appealing error page is displayed to visitors?

When handling server-side errors in PHP, it's important to catch exceptions and errors gracefully to display a visually appealing error page to visitors. This can be achieved by using try-catch blocks to catch exceptions and displaying a custom error page using a user-friendly message.

<?php
try {
    // Code that may throw an exception or error
} catch (Exception $e) {
    // Display a custom error page with a user-friendly message
    header("HTTP/1.1 500 Internal Server Error");
    include("error_page.php");
    exit;
}
?>