SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: check syntax

  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    check syntax

    Hi,

    I wonder if they are right and functioning the same ?

    Code PHP:
    1/  if(isset($_SESSION['id']) && isset($_SESSION['username'])) {...}
    2/  if(isset($_SESSION['id'],$_SESSION['username'])) {...}
    3/  if(isset($_SESSION['id'] && $_SESSION['username'])) {...}

  2. #2
    SitePoint Addict fattyjules's Avatar
    Join Date
    Dec 2005
    Posts
    295
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The first and the second ones behave exactly the same way.

    The first one calls isset() twice, the second one calls isset() once, but checks for the existence of two variables.

    The third one is not valid PHP - the clause passed to isset() is a value, not a variable.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •