...

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



ArcticFox
01-24-2007, 07: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.

:(

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


<?php

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

?>


ref:
http://us2.php.net/reserved.variables

ArcticFox
01-24-2007, 08:48 PM
*edited*

Got it.

Thank you!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum