php

Go to another page in PHP

<?php
    header("Location: page_name.php"); //You can pass relative url of page or full url of page
    exit();
?>

If you want to redirect to a page in PHP, you can use the 'header' function for that. You can either pass the full URL of the page to the Location or relative path of the page.

Example 1

Passing relative URL of the page

<?php
    header("Location: ../article/blog.php");
    exit();
?>

Example 2

Passing full or absolute URL to the Location

<?php
    header("Location: https://devsheet.com/u/");
    exit();
?>
Was this helpful?