Results 1 to 4 of 4

Thread: [RESOLVED] PHP - Clearing up variables

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Resolved [RESOLVED] PHP - Clearing up variables

    Hi

    Another quick and easy question.

    Once I'm at the bottom of the php file, so I need to unset any/all the variables I used ?
    Also, if I destroy a session, will that clear the session variables as well ?

    Just curious, and want to try to get into some good practices...

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: PHP - Clearing up variables

    Use unset more info on google

    http://www.php.net/manual/en/function.session-unset.php

    Example

    Quote Originally Posted by mwgamera
    PHP Code:
    <?php 
    session_start
    (); 
    var_dump($_SESSION); 
    $a =& $_SESSION
    unset(
    $_SESSION); 
    $a['x'] = 1// $a refers to the original $_SESSION 
    $_SESSION['x'] = 2// new unrelated array 
    session_write_close(); 
    // saved session contains x => 1 
    ?>
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: PHP - Clearing up variables

    Quote Originally Posted by Ecniv View Post
    Hi

    Another quick and easy question.

    Once I'm at the bottom of the php file, so I need to unset any/all the variables I used ?
    Also, if I destroy a session, will that clear the session variables as well ?

    Just curious, and want to try to get into some good practices...

    Vince
    It is not necessary to unset all of your variables from your page.

    When you destroy a session, all session variables are... destroyed, so they no longer exist.


    Quote Originally Posted by Nightwalker83 View Post
    Your post didn't answer any question the OP asked.

  4. #4

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: PHP - Clearing up variables

    Thanks

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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