Re: isset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, April 14, 2007 8:36 pm, 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

It *is* set.

It just happens to be the empty string.

That is VERY different from not being set at all.

If you do not want to allow the empty string as a valid input, that
should, imho, be handled by your data validation routines, which
happen after your business logic of doing whatever based on isset()

http://php.net/strlen is a good one for that.

In other words, use isset() to decide what the user is trying to do
first.

Then use data validation to decide if they have provided
valid/suitable input.  If the input is egregious enough (i.e., no
normal human would ever generate that state) you can respond
differently with, say, die("hacker");

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux