Re: isset

From: Date: Sun, 15 Apr 2007 01:48:47 +0000
Subject: Re: isset
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-252957@lists.php.net to get a copy of this message
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!"; } >

« previous php.general (#252957) next »