How can you determine which page (URL) called the current page in PHP?

To determine which page (URL) called the current page in PHP, you can use the $_SERVER['HTTP_REFERER'] variable. This variable contains the URL of the previous page that linked to the current page. You can use this information to track where the user came from before landing on the current page.

if(isset($_SERVER['HTTP_REFERER'])){
    $previousPage = $_SERVER['HTTP_REFERER'];
    echo "Previous page URL: " . $previousPage;
} else {
    echo "No previous page information available.";
}