[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
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
?>
Re: PHP - Clearing up variables
Quote:
Originally Posted by
Ecniv
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
Your post didn't answer any question the OP asked.
Re: PHP - Clearing up variables