How can PHP be used to determine if the HTTP REFERER is present and take appropriate actions based on its presence or absence?

To determine if the HTTP REFERER is present in a request, you can check the $_SERVER['HTTP_REFERER'] variable in PHP. If the variable is set, it means that the request has a REFERER header. You can then take appropriate actions based on its presence or absence.

if(isset($_SERVER['HTTP_REFERER'])) {
    // REFERER is present, take appropriate actions
    echo "REFERER is present: ".$_SERVER['HTTP_REFERER'];
} else {
    // REFERER is not present, take appropriate actions
    echo "REFERER is not present";
}