<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Variable Assignment, Exception Handling, and Destructors in PHP</title>
	<atom:link href="http://www.michiknows.com/2007/03/02/variable-assignment-exception-handling-and-destructors-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.michiknows.com/2007/03/02/variable-assignment-exception-handling-and-destructors-in-php/</link>
	<description>Insights on the IT world by Michi Kono</description>
	<lastBuildDate>Wed, 28 Jul 2010 00:04:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Matt</title>
		<link>http://www.michiknows.com/2007/03/02/variable-assignment-exception-handling-and-destructors-in-php/#comment-14830</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Thu, 31 Jul 2008 19:05:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.michiknows.com/2007/03/02/variable-assignment-exception-handling-and-destructors-in-php/#comment-14830</guid>
		<description>&quot;For those of you still reading, and understanding what I’m talking about, I have another point to add: destructors fire before the exception is thrown out! As in, as soon as the program sees the throw keyword and we leave the constructor, the destructor fires! I imagine this is because since the variable was never assigned, it’s just a dangling variable in memory, and thus gets cleaned up immediately.&quot;

The reason the destructor fires before the exception is thrown (at least for other languages like C++) is because the exception causes a jump to a new code block and there is no guarantee that the catching code block would--or could--send you back to the throwing code block. Since it is unlikely that the catching block would do that, the destructor has to be called before the exception is thrown or anything allocated in the constructor would become a memory leak (it would never be destructed).</description>
		<content:encoded><![CDATA[<p>&#8220;For those of you still reading, and understanding what I’m talking about, I have another point to add: destructors fire before the exception is thrown out! As in, as soon as the program sees the throw keyword and we leave the constructor, the destructor fires! I imagine this is because since the variable was never assigned, it’s just a dangling variable in memory, and thus gets cleaned up immediately.&#8221;</p>
<p>The reason the destructor fires before the exception is thrown (at least for other languages like C++) is because the exception causes a jump to a new code block and there is no guarantee that the catching code block would&#8211;or could&#8211;send you back to the throwing code block. Since it is unlikely that the catching block would do that, the destructor has to be called before the exception is thrown or anything allocated in the constructor would become a memory leak (it would never be destructed).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
