What are the best practices for handling conditional statements in PHP for page redirection?

When handling conditional statements for page redirection in PHP, it is important to use the header() function to redirect the user to a different page based on a condition. Make sure to include an exit() statement after the header() function to prevent any further code execution. Additionally, always sanitize and validate any input data before using it in the conditional statement to prevent security vulnerabilities.

// Example of handling conditional statements for page redirection in PHP
if($condition) {
    header("Location: newpage.php");
    exit();
} else {
    header("Location: anotherpage.php");
    exit();
}