How can developers properly access server variables like HTTP_REFERER in PHP?

To properly access server variables like HTTP_REFERER in PHP, developers can use the $_SERVER superglobal array. This array contains information about headers, paths, and script locations. To access the HTTP_REFERER variable specifically, developers can use $_SERVER['HTTP_REFERER'].

$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'No referer';
echo $referer;