What is the function in PHP to check the referring page?

In PHP, you can check the referring page by accessing the $_SERVER['HTTP_REFERER'] variable. This variable contains the URL of the page that referred the current page. You can use this information to determine where the user came from and take appropriate actions based on that.

$referring_page = $_SERVER['HTTP_REFERER'];

if($referring_page){
    // Do something based on the referring page
    echo "You came from: " . $referring_page;
} else {
    // Handle case where there is no referring page
    echo "No referring page found";
}