What are common methods for creating custom error pages in PHP when the provider restricts changes to htaccess?

When the provider restricts changes to the .htaccess file, you can still create custom error pages in PHP by using the header() function to send the appropriate HTTP response code along with the custom error page content. You can create separate PHP files for each error page (e.g., error404.php for a 404 Not Found error) and include them in your main PHP files where needed.

<?php
// error404.php
header("HTTP/1.0 404 Not Found");
?>
<!DOCTYPE html>
<html>
<head>
    <title>404 Not Found</title>
</head>
<body>
    <h1>404 Not Found</h1>
    <p>The page you are looking for could not be found.</p>
</body>
</html>