Re: how to recognize local or server execution?

From: Date: Sun, 28 Oct 2001 03:20:47 +0000
Subject: Re: how to recognize local or server execution?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-72604@lists.php.net to get a copy of this message
"Dl Neil" <PHPml@DandE.HomeChoice.co.uk> wrote in message news:0a4e01c15e72$c47db560$a516100a@jrbrown... > Thanks for the idea. I have just resurrected and had another play with my 'testbench.php', running it from both > IE/Apache and in a DOS box. > > It includes the following code: [...] Thanks (also thanks to the others for the useful comments & ideas). I don't have $HTTP_SERVER_VARS["SERVER_NAME"] or $GLOBALS["SERVER_ADDR"] or $SERVER_SOFTWARE probably because my server is netscape ("nsapi"?). They are all blank. Yes I declared them 'global'. I ended up with these functions which seem to do the trick, at least for my server and NT. function isonserver() { global $PHP_SELF,$argc; return $argc==0 && isset($PHP_SELF) && $PHP_SELF; } function getpagename() { global $PHP_SELF,$argv; return basename(isonserver() ? $PHP_SELF : $argv[0]); } function getlinedelimiter() { return isonserver() ? "\n" : "\r\n"; } The pagename is critical to my site, because the code needs the page name to recognize certain suffixes and 'special page names. Perhaps it is only sufficient to test for $PHP_SELF and not $argc, but I threw in $argc==0 anyway. -- John A. Grant * I speak only for myself * (remove 'z' to reply) Radiation Geophysics, Geological Survey of Canada, Ottawa If you followup, please do NOT e-mail me a copy: I will read it here

« previous php.general (#72604) next »