Afan Pasalic wrote:
>
> Jochem Maas wrote:
>> Richard Kurth wrote:
>>
>>> What do you do when isset does not work? If I send data in a
>>> $_REQUEST['var'] like
>>> if (isset($_REQUEST['var'])) {
>>> }
>>> Put var has no data it still says it is set. Because $_REQUEST['var'] = ""
>>> and isset thinks "" is set
>>>
>>
>> php -r ' $r = array("foo" => "");
>> var_dump(isset($r["foo"]),empty($r["foo"]));'
>>
>> so empty() should give you the result your looking for ...
>> some tips:
>>
>> 1. generally use $_GET or $_POST in preference to $_REQUEST
>> 2. be specific about your input validation, e.g.:
>>
>> if (isset($_GET['var']) && ($_GET['var'] == 'foo')) {
>> echo "got it!";
>> }
>>
> I always wondered about this. if $_GET['var'] == 'foo' is true, isn't
> automatically isset($_GET['var']) true too?
> I mean, isn't
> if ($_GET['var'] == 'foo')
> {
> echo "got it!";
> }
> just enough?
it doesn't cover the situation where $_GET['var'] doesn't exist,
and using uninitialized var is not recommended.
of course it's your call whether you write/run code that spits out
E_NOTICEs all over the place due to usage of uninitialized vars.
>
> -afan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php