redirect to another page php code example

Example 1: php go to another page

<?php header("Location: anotherDirectory/anotherFile.php"); ?>

Example 2: php redirect to page

header("Location: /");
exit();

Example 3: redirect in php

header("location: THE LOCATION"); //"THE LOCATION", put in a URL or directory to redirect to. For example, header("location: https://google.com/"); or header("location: ../../images/dog/");

Example 4: how to redirect to php

function location($where){
	echo '<script>window.location.href="'.$where.'"</script>';
}


location("https://youtube.com");

Tags:

Php Example