#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,689
    Rep Power
    171

    What is the differnece between !$var and !isset($var)


    What is the differnece between
    PHP Code:
    if(!$nights) { ...} 
    and
    PHP Code:
    if(!isset($nights)) { ...} 
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    !$nights checks for anything loosely equal to false, like false, empty strings, null, 0, and "0". If it has not been defined you'll get a warning.

    !isset($nights) checks (a) the variable has not been defined at all yet or (b) has a value of null.

IMN logo majestic logo threadwatch logo seochat tools logo