|  | Posted by Jerry Stuckle on 12/05/07 11:56 
Ojas wrote:> On Nov 29, 4:51 pm, Bruno Rafael Moreira de Barros
 > <brunormbar...@gmail.com> wrote:
 >>> Thanks to all of you for replying but i still think there should be a
 >>> way to know that. Actually someone may have to implement a check on
 >>> the basis of that. Unavailability of the functionality can break the
 >>> logic!!
 >> Not wanting to be pessimistic or contraditory, I think what he meant
 >> was how to find a way to know which application executed the request.
 >>
 >> If you open a request to a PHP script from another PHP script, there
 >> will be a PHP user agent (dont know its name from my head), whilst on
 >> a browser, the browsers details will be sent. Lets just say with PHP,
 >> you can check if its command line by checking IF $argc and $argv
 >> exist, to check if its a browser, compare it to a list of known
 >> browsers (PHP.net has one huge file for that) and if its not run on
 >> command line, if its not run on a known browser, then it can only be
 >> another application.
 >>
 >> Is that what you were looking to know, Ojas?
 >
 > You are right Bruno Rafael. I am willing to know the type of
 > application sending request to the server to run a PHP script (i think
 > it should be clear to all other ones that i am not asking for how
 > script will run on client side.)
 >
 
 PHP scripts do not run on the client side.
 
 > As you have specified, 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?
 >
 > Ojas.
 >
 
 As he said - if it is from the command line, $argc and $argv will exist,
 as will $_SERVER['argc'] and $_SERVER['argv'].  But you shouldn't be
 even trying to access them unless you know they exist - they will give a
 NOTICE if you have errors enabled and displayed (which you should in a
 development environment).
 
 Check out isset() and array_key_exists(), for instance.
 
 --
 ==================
 Remove the "x" from my email address
 Jerry Stuckle
 JDS Computer Training Corp.
 jstucklex@attglobal.net
 ==================
  Navigation: [Reply to this message] |