How to get the previous page in php

Imagine how this works, your in http://your-site.com/page-A and then you go to http://your-site.com/page-b, question is how would you get the url of http://your-site.com/page-A.

It’s easy, just use

$_SERVER['HTTP_REFERER']

In this way, you can get the url of the previous page.
The $_SERVER is a pre defined variable that has lots of useful information, you can just check it out when you do

print_r($_SERVER);

Hope this helps someone!
Have a happy coding! :)