Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #17464 > unrolled thread

If an arg is not there...

Started bybit-naughty@hotmail.com
First post2017-06-02 12:58 -0700
Last post2017-06-02 22:45 +0200
Articles 2 — 2 participants

Back to article view | Back to comp.lang.php


Contents

  If an arg is not there... bit-naughty@hotmail.com - 2017-06-02 12:58 -0700
    Re: If an arg is not there... "J.O. Aho" <user@example.net> - 2017-06-02 22:45 +0200

#17464 — If an arg is not there...

Frombit-naughty@hotmail.com
Date2017-06-02 12:58 -0700
SubjectIf an arg is not there...
Message-ID<ed12fab8-a423-43c4-a004-9ccc8ccafb5b@googlegroups.com>
If I pass an arg to a PHP prog, how do I read it? Like site.com/prog.php?arg=cool - how do I read arg and get the word "cool" in my program?

And - if an arg is not there, like, say above, the argument "arg2" is not there, only "arg" - whatever method is used for reading args (eg. $_REQUEST something or whatever), that will be blank for arg2, right? (eg. $_REQUEST["arg2"] etc.)

[toc] | [next] | [standalone]


#17465

From"J.O. Aho" <user@example.net>
Date2017-06-02 22:45 +0200
Message-ID<epe13jFbr6iU1@mid.individual.net>
In reply to#17464
On 06/02/17 21:58, bit-naughty@hotmail.com wrote:
> If I pass an arg to a PHP prog, how do I read it? Like site.com/prog.php?arg=cool - how do I read arg and get the word "cool" in my program?

$_GET[] if you just expect requests which has the value in the URL as in 
your example.

$_REQUEST[] if you expect both POST (<form><input type='text'...><input 
type='submit'...></form>) and GET (as in your example).



> And - if an arg is not there, like, say above, the argument "arg2" is not there, only "arg" - whatever method is used for reading args (eg. $_REQUEST something or whatever), that will be blank for arg2, right? (eg. $_REQUEST["arg2"] etc.)

If arg2 is sent but with an empty value, then the $_GET['arg2'] will be 
empty, if arg2 is completely missing from the request, then there ain't 
a $_GET['arg2']


Please read at least these pages:
http://php.net/manual/en/reserved.variables.get.php
http://php.net/manual/en/reserved.variables.post.php
http://php.net/manual/en/reserved.variables.request.php
http://php.net/manual/en/function.isset.php
http://php.net/manual/en/function.empty.php

There you will find the answers you look for.


-- 

  //Aho

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web