What is the best practice for automatically redirecting users in PHP without requiring user input?

When automatically redirecting users in PHP without requiring user input, the best practice is to use the header() function to send a raw HTTP header to the browser, instructing it to redirect to a new location. This method is efficient and does not rely on JavaScript or meta tags for redirection.

<?php
// Redirect to a new location
header("Location: http://www.example.com");
exit;
?>