What are some common pitfalls to avoid when creating a custom 404 page in PHP?

One common pitfall to avoid when creating a custom 404 page in PHP is not properly handling error headers. It is crucial to send a 404 HTTP header along with the custom error page to inform the browser that the requested page was not found. Failing to send the correct header may result in search engines indexing the custom error page as a valid page, leading to potential SEO issues.

<?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 does not exist.</p>
</body>
</html>