Results 1 to 7 of 7

Thread: [Resolved] isset() Question

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] isset() Question

    I know that isset() checks to see if a variable exists. So if I have:

    PHP Code:
    $var '';

    if (isset(
    $var)) {


    The variable exists, so will that return TRUE or FALSE? What about variables equal to NULL?
    Last edited by The Hobo; Oct 15th, 2003 at 01:53 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Lively Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    102
    Ok isset will return True if the variable exists and false if it doesn't I am almost pos that isset has nothing to do with nulls. There is another function called isempty that returns true if the variable is empty. to this funciton empty is no value or null. so if you have a value that had nothing assigned to it or has a null value assigned to it the isempty function will return true. So if you are looking weather a variable is in use it is better to use isempty.
    ===============
    Tek
    ===============

  3. #3
    The PHP manual is the best place to find this trye of stuff. Its the easiest to follow programming manual I've ever read

    isset() function reference

    Returns TRUE if var exists; FALSE otherwise.

    If a variable has been unset with unset(), it will no longer be set. isset() will return FALSE if testing a variable that has been set to NULL. Also note that a NULL byte ("\0") is not equivalent to the PHP NULL constant.

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I have the downloadable manual. Use it all the time.

    However, what you posted DOESN'T answer my question.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Which, I just checked the manual again. I was looking in the text for my answer before, but the example answered it:

    $var = '';

    // This will evaluate to &true; so the text will be printed.
    if (isset($var)) {
    print "This var is set set so I will print.";
    }
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Lively Member
    Join Date
    Sep 2003
    Location
    USA
    Posts
    102
    Sry I thought I answered u'r question fully I should have said that your example would return true as the varaiable is set to a blank space.
    ===============
    Tek
    ===============

  7. #7

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Thanks.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width