NYCPHP Meetup

NYPHP.org

[nycphp-talk] Any way to check for CLI?

DeWitt, Michael mjdewitt at alexcommgrp.com
Fri Apr 4 10:11:51 EST 2003


I don't know if this is the right way, but it might work:

'PHP_SELF' 
	The filename of the currently executing script, relative to the
document root. For instance, $_SERVER['PHP_SELF'] in a script at the address
http://example.com/test.php/foo.bar would be /test.php/foo.bar. 
	If PHP is running as a command-line processor, this variable is not
available. 
Also, I am curious what get_browser() returns or 'HTTP_USER_AGENT'  under
CLI
Mike

> -----Original Message-----
> From:	Mark Armendariz [SMTP:nyphp at enobrev.com]
> Sent:	Friday, April 04, 2003 10:05 AM
> To:	NYPHP Talk
> Subject:	[nycphp-talk] Any way to check for CLI?
> 
> Do any of you by any chance know how to check if a script is called via
> command line or from a browser?
>  
> I have a script that is called from either one, and I need to change the
> output methods accordingly.  Looking at the phpinfo, I don't see any
> variable that seems like a solid "this is from the command line".
>  
> Oh, and to slip a second one in here.  What is $_SERVER['PWD']?  I
> noticed it shows the dir structure to the current file on my server,
> which is fantastic.  Is that what it's supposed to do?  And what does
> PWD stand for.
>  
> Muchos Thanks and have a great Friday!!!
>  
> Mark
> 
> 
> 
> --- Unsubscribe at http://nyphp.org/list/ ---
> 



More information about the talk mailing list