What are the advantages and disadvantages of using meta refresh for redirecting in PHP compared to header('location:...')?

When redirecting in PHP, using header('location:...') is the preferred method as it sends a proper HTTP header to the browser and is more efficient. On the other hand, using meta refresh for redirection involves adding a meta tag in the HTML code, which can be less reliable and may not work for all browsers.

// Using header('location:...') for redirection
header('Location: https://www.example.com');
exit;