What are some best practices for handling 400 error pages in PHP?

When handling 400 error pages in PHP, it is important to provide a user-friendly error message and possibly redirect the user to a relevant page. One common approach is to create a custom error page for 400 errors and display it when necessary. You can achieve this by using the header() function to set the appropriate HTTP status code and include the custom error page content.

<?php
// Set the HTTP status code to 400
header("HTTP/1.0 400 Bad Request");

// Include the custom error page content
include("error400.php");
?>