note 44455 added to language.oop5.decon
| From: | php-general at lists dot php dot net | Date: | Fri, 06 Aug 2004 16:07:02 +0000 |
| Subject: | note 44455 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79848@lists.php.net to get a copy of this message | ||
Bug or Feature?
For example a Session class:
<?php
class Session {
...
public function __destruct() {
echo $this->sessionId();
// Store session data into db
$this->write($this->sessionId());
}
...
}
...
// Using the class:
$db = DbFactory::create('mysqli');
$db->connect(...);
$session = new Session($db);
$_SESSION['var1'] = 1;
$_SESSION['var2'] = 2;
?>
Problem?!: The destructor does not work as expected!
=> "echo ..." works fine!
=> "write..." does not work! ???
Solution:
unset($session);
If the session object is manually unset at the end of the script, everything works fine. Nice
Feature or Bug?
----
Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+44455
Delete -- http://master.php.net/manage/user-notes.php?action=delete+44455&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+44455&report=yes
Search -- http://master.php.net/manage/user-notes.php