Does if(empty()) function carry session values to the next page?

Discussion in 'PHP' started by ketting00, May 13, 2011.

  1. #1
    Hi,

    I've created a user-login system website and had read somewhere long ago that using if(empty()) function is better than using if(isset()) function in term of scalable.

    I ignored it at the time and just interested in it recently because if(isset()) have limited usage.

    since I never use if(empty()) before I was wondering that using it will carries the session values from one page to the another, and allover the web as long as browser still open like if(isset())? If so, I use definitely recoding my web.

    Thanks in advance.
     
    ketting00, May 13, 2011 IP
  2. JoelLarson

    JoelLarson Peon

    Messages:
    61
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The differences between isset() and empty() are:
    isset() checks only for NULL. If the variable is NULL, then it returns false.
    empty() checks for:
    So isset() would be faster, but empty() has a larger threshold for "empty" variables. They can be used independently, no matter what. They also don't affect the $_SESSION variables (or any for that matter) because it's simply a TRUE/FALSE check of the variable.
     
    JoelLarson, May 13, 2011 IP
  3. hyperboards

    hyperboards Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I usually see both functions used together, as in:
    if(isset() && !empty())

    They both have their own individual uses separately, too.
     
    hyperboards, May 13, 2011 IP
  4. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #4
    Thanks for suggestions. This truly saves my day. The project I am working on is large and I'm just working alone.
     
    ketting00, May 14, 2011 IP