What is the common practice for redirecting in PHP using header(location)?

When redirecting in PHP using the header(location) function, it is important to ensure that no output has been sent to the browser before the header is set. This is because headers must be sent before any actual output to the browser. To avoid any errors, it is recommended to use the exit() function after setting the header to immediately stop script execution.

<?php
header("Location: https://www.example.com");
exit();
?>