|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-12-04 13:47 UTC] dmitry@php.net
[2006-12-04 20:14 UTC] magic dot bitbucket at gmail dot com
[2006-12-04 20:30 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 23:00:02 2025 UTC |
Description: ------------ When throwing an Exception and not catching it, Object destructors don't get called. I don't know if this is a bug or a feature, but surely it isn't expected behaviour and it isn't documented. This allows Objects to go out of scope without the destructor being called and makes destructors useless as cleanup has to be done manually before even thinking about throwing an Exception. Reproduce code: --------------- #!/usr/bin/php <?php class ExceptionTest { public function __construct(){} public function __destruct() { echo "hilfe mein leben!\n"; } } $test=new ExceptionTest(); throw new Exception('why are the destructors not called?', 666); ?> Expected result: ---------------- I would expect __destruct() to be called when throwing the Exception. Actual result: -------------- __destruct() isn't called.