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


Groups > comp.lang.php > #17465

Re: If an arg is not there...

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: If an arg is not there...
Date Fri, 2 Jun 2017 22:45:39 +0200
Lines 31
Message-ID <epe13jFbr6iU1@mid.individual.net> (permalink)
References <ed12fab8-a423-43c4-a004-9ccc8ccafb5b@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net FUBsSnpj1TqYcWYPdEE7FATTlOSn73MqoqD6FtVZMz7aj8Eudy
Cancel-Lock sha1:wzZyK8cloR/zMKM3Y8gPgR0joOk=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1
In-Reply-To <ed12fab8-a423-43c4-a004-9ccc8ccafb5b@googlegroups.com>
Content-Language en-GB
Xref csiph.com comp.lang.php:17465

Show key headers only | View raw


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

Back to comp.lang.php | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

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

csiph-web