Is it possible to retrieve the address of the last visited page within a website using PHP?

To retrieve the address of the last visited page within a website using PHP, you can use the $_SERVER['HTTP_REFERER'] variable. This variable contains the URL of the previous page that linked to the current page. You can store this value in a variable and use it as needed in your PHP script.

$lastVisitedPage = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'No previous page';
echo 'Last visited page: ' . $lastVisitedPage;