Re: testing for value in $HTTP_COOKIE_VARS
| From: | Steve Yates | Date: | Thu, 04 Apr 2002 00:01:05 +0000 |
| Subject: | Re: testing for value in $HTTP_COOKIE_VARS | ||
| References: | 1 2 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-12924@lists.php.net to get a copy of this message | ||
To follow up with the group, I received an answer via e-mail within a
few minutes with two methods (thanks AB).
(1)
$foo = @$HTTP_COOKIE_VARS["foo"];
# Where the @ suppresses the warnings on the call.
if ($foo)
{
}
(2) The one I ended up using (modified a bit):
if ((isset($HTTP_COOKIE_VARS["foo"]) and ($HTTP_COOKIE_VARS["foo"] ==
'value'))
{
}
PHP short circuits the logic so method 2 doesn't throw the error on the
value test. Or of course you can put the test for the value inside the if
{}. Also for environment variables you can use getenv() rather than the
array.
- Steve Yates
- * <- Tribble. ! <- Tribble With A Mohawk.
/ Taglines by Taglinator 2.5 - www.srtware.com /