Folks:

On Fri, Aug 02, 2002 at 07:01:38PM +0200, Jürgen wrote:
> 
> Why would i ever want to use isset() then?

Because sometimes you just want to check if something is set due to null, 
'' and 0 being important.

   $var = '';
   empty($var);  // evaluates to true
   isset($var);  // evaluates to true

   unset($var);
   empty($var);  // evaluates to true
   isset($var);  // evaluates to false


> If i understood you correctly, would the following
> 
> op = isset($_GET['op']) && !empty($_GET['op']) ? $_GET['op'] : '';
> 
> be the same as
> 
> op = !empty($_GET['op']) ? $_GET['op'] : '';

Yes.  They do the same thing.  Couple things to think about, though.  If 
$_GET['op'] is 0, those commands will turn it into ''.  Probably not what 
you want.  Also, though less important, if it's already '', there's no 
need to do the step of resetting it to ''.  Sometimes, a cleaner test is:

  $op = isset($_GET['op']) ? $_GET['op'] : '';

--Dan

PS:  Don't be lazy.  Trim unneeded parts of prior postings.

-- 
               PHP classes that make web design easier
        SQL Solution  |   Layout Solution   |  Form Solution
    sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY     v: 718-854-0335     f: 718-854-0409

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

Reply via email to