How can the use of example domains like example.com be beneficial when testing PHP header redirection code?

When testing PHP header redirection code, using example domains like example.com can be beneficial because they are reserved for documentation and testing purposes. By using example domains, you can ensure that your code is not unintentionally redirecting users to a live website. This can help prevent any unintended consequences or disruptions to real users.

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