Why doesn't !="" && !="" work?

Discussion in 'PHP' started by misohoni, Mar 11, 2014.

  1. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #21
    The isset() calls are a little redundant, if you only want to know if the variable has a (non-empty) value.

    empty() is a language construct (not a function), that just like isset(), won't throw error notices on undefined variables/indices.
     
    nico_swd, Mar 12, 2014 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #22
    'empty' on a unset variable should throw a warning; or at least it used to. Hmm... did they finally get rid of that?
     
    deathshadow, Mar 12, 2014 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #23
    According to the manual:
    http://www.php.net/manual/en/function.empty.php

    Not sure if it has always been like that, though.
     
    nico_swd, Mar 13, 2014 IP