Are there any common pitfalls to avoid when using PHP for automatic redirection?

One common pitfall to avoid when using PHP for automatic redirection is not including an exit or die statement after the header function is called. This can lead to unexpected behavior or errors since the script will continue to execute after the redirection headers are sent. To solve this issue, always remember to include an exit or die statement immediately after using the header function for redirection.

header("Location: http://example.com");
exit;