define header in different file php

PHP
<?php
// This will just redirect you to example.com
$url = "https://example.com";
header("Location: $url");  
?><html>
<?php
/* This will give an error. Note the output
 * above, which is before the header() call */
header('Location: http://www.example.com/');
exit;
?>

header("Location: http://example.com/myOtherPage.php");
die();
Source

Also in PHP: