Why is it recommended to use PHP header() function for page redirection instead of meta refresh tag?

Using the PHP header() function for page redirection is recommended over the meta refresh tag because it allows for more control over the redirection process and is more reliable. The header() function sends an HTTP header to the browser, instructing it to redirect to a different page, while the meta refresh tag relies on the browser to automatically refresh the page after a specified time, which can be inconsistent across different browsers.

<?php
// Redirect to a different page
header("Location: https://www.example.com");
exit();
?>