note 44455 deleted from language.oop5.decon by nlopess
| From: | nlopess@php.net | Date: | Sat, 07 Aug 2004 16:41:51 +0000 |
| Subject: | note 44455 deleted from language.oop5.decon by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-74146@lists.php.net to get a copy of this message | ||
Note Submitter:
----
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?