Advanced Search

Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: isset/unset

  1. #1
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation isset/unset

    Hello ,

    Can anyone please explain the isset and unset functions in php in relation to javascript (this will make it easier)

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I have a script.
    PHP Code:
    <?php
    $var 
    "some string"
    if(isset($var)) { //Returns true, the variable is set.
      
    unset($var); // undoes the variable
      
    echo $var//echoes nothing.
    }
    ?>
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for that simple example !

  4. #4
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there anything else to isset function apart from checking if things are set ?

  5. #5
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    I dont think so.
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  6. #6
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well thanks for your help

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It can check if a given item exists in an array, too.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What do you mean ? do you mean something like isset(sesion_start()) ?

  9. #9
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    No he means:
    PHP Code:
    <?php
    $arr 
    = array(
    "key"=>"val",
    "num"=>"1234",
    "letter"=>"abc",
    "nonalphnum"=>"!@#$"
    );
    if(isset(
    $arr["num"])){
      echo 
    "The value is set"//echos if it is set
      
    echo $arr["key"]; //echos "val" 
      
    unset($arr["key"]);
      echo 
    $arr["key"]; //echos nothing, because it doesnt exist.
    }
    ?>
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  10. #10
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK thanks i see

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
  •