Re: isset

From: Date: Mon, 16 Apr 2007 22:27:36 +0000
Subject: Re: isset
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-253067@lists.php.net to get a copy of this message
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?

« previous php.general (#253067) next »