[thelist] PHP environment variables

Joe Crawford jcrawford at avencom.com
Mon Aug 13 17:01:32 CDT 2001


Robin Hastings wrote:
> I'm trying to set up a 404 page that will email me whenever someone hits it. All
> is well, except that I can't figure out how to get the current URL (the bad
> page) to show up in PHP using IIS 4. I gather that in Apache there is an
> environment variable "REQUEST_URI" that does just what I want, but IIS refuses
> to acknowledge it. I'm not finding anything helpful at the MS knowledge base or
> in my phpinfo() page. Is there something out there that will do this, or am I
> just outta luck? Thanks!!

Those environment variables are Apache specific I think. This code
snippet works for me.

<?
$where_they_are = 'http://' . $SERVER_NAME . $REQUEST_URI;
$recipientlist='me at myself.dom';
$emailsubject="Error @ $where_they_are";
$emailbody="someone came to $where_they_are
via $HTTP_REFERER
from ip address:  $REMOTE_ADDR";
$firstname='Myself.domm';
$lastname='Error Notification Email';
$email='myrobot at myself.dom';
mail(
$recipientlist, $emailsubject, $emailbody,
"From: $firstname $lastname <$email>\nReply-To: $email\nX-Mailer: PHP/"
. phpversion());
?>

As the page at php.net says though:
http://www.php.net/manual/en/language.variables.predefined.php

"PHP provides a large number of predefined variables to any script which
it runs. Many of these variables, however, cannot be fully documented as
they are dependent upon which server is running, the version and setup
of the server, and other factors."

I'd look really close at your phpinfo() page though.

And check this out -- a side by side comparison! Pretty nifty - and just
for you folks doing PHP on IIS:

http://php.weblogs.com/Apache_IIS

	- Joe
-- 
...................  Joe Crawford \\ Web Design & Development
.....  mailto:jcrawford at avencom.com \\ http://www.avencom.com
.... San Diego \\ CA \\ USA \\ AVENCOM: Set Your Sites Higher




More information about the thelist mailing list