Re: Will $_GET throw an error? (no problem just doubt)
| From: | Cal Evans | Date: | Sat, 03 May 2003 16:33:37 +0000 |
| Subject: | Re: Will $_GET throw an error? (no problem just doubt) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-146283@lists.php.net to get a copy of this message | ||
Depending on how you have your error levels set, you will get a WARNING that
$_GET[???] does not exist.
A better way would be to use something like:
$key =
(exists($_GET['key'])?$_GET['key']:'someDefaultValueMeaningfulToYou';
This way you will not get a warning and $key will always have a meaningful
value.
HTH,
=C=
* Cal Evans
* http://www.christianperformer.com
* Stay plugged into your audience
----- Original Message -----
From: "Ryan A" <ryan@jumac.com>
To: <php-general@lists.php.net>
Sent: Saturday, May 03, 2003 10:41 AM
Subject: [PHP] Will $_GET throw an error? (no problem just doubt)
> Hi,
> I am converting my script to work if register globals are off...I have a
> simple question
>
> I have some variables that may or may not be sent from the server namely
> $key (and)
> $hash
> if one is sent the other wont be...so my question is if i declare both
like
> so:
> $key = $_GET['key'];
> $hash = $_GET['hash'];
> but what happens when only one is sent and not the other? will i get an
> error/warning or.....?
>
> kindly reply.
>
> Cheers,
> -Ryan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>