note 48177 added to function.unset
| From: | harycary at netscape dot net | Date: | Tue, 14 Dec 2004 17:56:18 +0000 |
| Subject: | note 48177 added to function.unset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81787@lists.php.net to get a copy of this message | ||
If you ever have to unset all the variables of a class from within a funciton of that class use the
following code:
<?php
class User
{
function User_login ( ... )
{...}
function User_logout ( $greeting )
{
...
foreach ( array_keys ( get_object_vars ( &$this ) ) as $val)
{ unset( $this->$val ); }
$this->greeting = $greeting;
...
}
}
?>
If anyone knows of a more effective way please post a reply.
----
Manual Page -- http://www.php.net/manual/en/function.unset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48177
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48177&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48177&report=yes
Search -- http://master.php.net/manage/user-notes.php