How can PHP be used to determine the origin of a website visitor?
To determine the origin of a website visitor in PHP, you can use the $_SERVER superglobal variable to access the HTTP_REFERER header, which contains the URL of the page that referred the user to the current page. This can be useful for tracking where your website traffic is coming from or implementing custom logic based on the referring URL.
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'Direct visit';
echo "Visitor came from: " . $referrer;