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

Your name:

Reply:


Posted by Ojas on 12/06/07 04:05

On Dec 6, 8:21 am, NC <n...@iname.com> wrote:
> On Dec 5, 1:18 am, Ojas <contacto...@gmail.com> wrote:
>
>
>
> > if the request has been sent through command line, $argc &
> > $arv will exists whether having any values or not but since
> > we can access these values from $_SERVER (or $_ENV not sure
> > about it) which itself is an array, not set $_SERVER['argc']
> > is equivalent to null $_SERVER['argc'], accessing the
> > $_SERVER['argc'] will result to null values in both cases,
> > then how one can distinguish these cases?
>
> There's no need to. If the script is running from the command line, a
> call to php_sapi_name() will return 'cli'.
>
> Cheers,
> NC

Hi! all,

NC has provided a very useful point of using php_sapi_name to detect
the same. I tried to print 'PHP_SAPI' on my system and got the
following result:

Browser: apache2handler
Command Prompt: cli

I think it is of great help and we are going to have a robust
solution. Meanwhile, i would appreciate if anyone of you could share
the list of all possible php sapi (along with their possible
application from which they will be in existence).

And yes Jerry Stuckle do provided the good way of distinguish between
'not set element' and 'null element' inside the array. I was known to
it, but somehow it get slipped out of my mind.

Cheers! NC & Jerry Stuckle.

To continue the discussion, i would like to extend it a little bit
further by asking how to detect whether a request to the server has
been made directly or using sockets or using CURL from the client side
application?

Ojas

[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

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