Capturing current URL to variable

Hey guys, I got a simple question if someone has the time to help out.

Basically I want to capture the url variable a visitor has come from. For example I have an index page which will be on several different servers, they all will link back to my page. When the user clicks the link I want to get the URL that they came from and have it in a variable ready for my page to use.

Im guessing PHP would be the way to go but not too sure.

Thanks in advance.