What are the differences between using PHP, HTML meta-refresh, and JavaScript for URL redirection within an IF statement in PHP?

When redirecting users to a different URL within an IF statement in PHP, the most common methods are using PHP header function, HTML meta-refresh, or JavaScript. Using PHP header function is the most efficient and recommended way to redirect users, as it sends a raw HTTP header to the browser to redirect. HTML meta-refresh is a less preferred method as it relies on the browser to refresh the page after a specified time. JavaScript can also be used for redirection, but it may not be as reliable as the PHP header function.

<?php
if ($condition) {
    header("Location: newpage.php");
    exit();
}
?>