View Full Version : Echo URL where PHP 'include' located

01-24-2007, 08:45 PM
I've several pages I want logged. I had the entire PHP script on each page with the name of the page in the script (echo <div>Page: Index</div>, echo <div>Page: Email</div>, etc). Now I've put the script as its own .php page and have installed <?php include("php/logging.php"); ?> on all the pages I want to log.

The problem now is I have no idea which pages the logs are coming from. So I was thinking that I could just echo the URL of the page being logged at that time.

I know it's possible to document.write the URL with JS, but can it be done just PHP? I also thought about trying to echo the page title as well, but I dont know if that's even possible with PHP.


01-24-2007, 08:51 PM
You have a few options, something in the $_SERVER superglobal should suffice. Run this script and see some results:


foreach($_SERVER as $elm => $value)
echo $elm . ' - ' . $value . "<br>";



01-24-2007, 09:48 PM

Got it.

Thank you!