Jason Garber wrote:
Hello internals,
What is the best way, from within a php script, to tell that the
script is being run on the command line?
I've used if(defined('STDIN')) but that seems kind of kludgey.
If there is no better way, perhaps we could add constant called
(SAPI_TYPE = 'CLI') or something like that to the language to
facilitate this?
I think this is a good idea.
A hackish way is also
if (in_array($_SERVER['argv'][0], array($_SERVER['PHP_SELF'],'-'), 1))
//the second one is for php -r
Andrey
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php