Reply to Re: Script running under Command Prompt or Browser or some other application?

Your name:

Reply:


Posted by Norman Peelman on 12/06/07 11:45

Jerry Stuckle wrote:
> Kailash Nadh wrote:
>> On Nov 28, 5:34 am, Ojas <contacto...@gmail.com> wrote:
>>> Hi!,
>>>
>>> I just out of curiosity want to know how top detect the client side
>>> application under which the script is getting run. I mean to ask the
>>> how to know whether the script is running under Command Prompt or
>>> Browser or some other application?
>>>
>>> Ojas.
>>
>> Yep, when a php script is run from the commandline, the two variables
>> $argc and $argv (commandline arguments) are registered.
>> They might be empty, but they still would be registered when being run
>> from the commandline (and not when not in the commandline)
>> http://uk.php.net/features.commandline
>>
>> --
>> Kailash Nadh | http://kailashnadh.name
>>
>
> But that's server side. He asked about client side. And the answer is
> there is no good way.
>
>


If the OP is trying to determine weather the program is running via a
internet server/browser or command line (terminal) then check this out.

Either of these two lines will tell you:

echo PHP_SAPI."\n\r";

or:

echo php_sapi_name()."\n";

....see: http://us.php.net/manual/en/features.commandline.php

---
Norm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация