Re: how to recognize local or server execution?

From: Date: Fri, 26 Oct 2001 22:42:21 +0000
Subject: Re: how to recognize local or server execution?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-72527@lists.php.net to get a copy of this message
On Fri, 26 Oct 2001 23:12:17 +0100, DL Neil wrote: >Mark, >Backing John's question up by one iteration: is there a PHP >environment variable which can be used to >distinguish between code being run from the command line and code >being run in a browser? I guess the best way is to check for a common server var like $HTTP_SERVER_VARS["SERVER_NAME"] >- and the Million dollar question, sorry make that the M$ question: >will it also work under Windows? sure. >Please advise, >=dn > > >On Fri, 26 Oct 2001 17:18:37 -0400, John A. Grant wrote: >>I have an xxx.php page that runs on my Unix server. I also >>run php.exe on my NT box to generate the corresponding >>xxx.html file like this: >> c:\> php -q xxx.php > xxx.html >> >>The xxx.php file contains stuff like this: >> print "hello\n"; >> >>That means stdout from the server and the xxx.html file >>both contain \n. I would like the xxx.html file to contain >>\r\n so it can be viewed/edited with notepad. Yes, >>notepad and \r\n both suck, but that's another story... >> >>So I guess I would like my code to look like this: >> if(running php.exe on my NT box){ > >try: >if (strstr(php_uname(), "Windows")) { > >> $delimiter="\r\n"; >> }else{ >> $delimiter="\n"; >> } >> >>and then my code looks like: >> print "hello$delimiter"; >> >>How can I do this? >> >>-- >>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 >> >> >> >> > > >-- >Mark, maggelet@mminternet.com on 10/26/2001 > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list- >admin@lists.php.net > > > > -- Mark, maggelet@mminternet.com on 10/26/2001

« previous php.general (#72527) next »