What is the correct syntax for accessing the HTTP_REFERER variable in PHP?
When accessing the HTTP_REFERER variable in PHP, it is important to first check if it is set to avoid potential errors. This variable contains the URL of the page that referred the user to the current page. To access this variable, you can use the $_SERVER superglobal array and the key 'HTTP_REFERER'.
if(isset($_SERVER['HTTP_REFERER'])){
$referer = $_SERVER['HTTP_REFERER'];
echo "Referring URL: " . $referer;
} else {
echo "No referrer information available.";
}