What are some best practices for using header() and include() functions in PHP scripts?

When using the header() function in PHP scripts, it is important to make sure that no output has been sent to the browser before calling header() to avoid any "headers already sent" errors. Similarly, when using the include() function to include external files, it is recommended to use absolute paths or properly define the include path to ensure the file is included correctly.

<?php
ob_start(); // Start output buffering

// Your PHP code here

ob_end_clean(); // Clean (erase) the output buffer

header("Location: example.php"); // Redirect user to example.php
exit; // Stop script execution
?>