<?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: __halt_compiler() &#8211; how nuts?</title>
	<atom:link href="http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/</link>
	<description>News, opinion, and fresh thinking for web developers and designers. The official podcast of sitepoint.com.</description>
	<lastBuildDate>Sun, 08 Nov 2009 18:10:55 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: dreamscape</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-26590</link>
		<dc:creator>dreamscape</dc:creator>
		<pubDate>Fri, 26 May 2006 21:55:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-26590</guid>
		<description>The only thing bad about self installing PHP web scripts is that usually you&#039;re web root &amp; application root will have to have world-writeable permissions in order for PHP to write the files, and then once they are written, they will usually be owned by &quot;apache&quot;, &quot;nobody&quot;, or &quot;www&quot;, so you [your account user] won&#039;t be able to do shit with them unless PHP sets the permissions on the new files &amp; folders as world-writable.

The only ways to avoid that is to run PHP as your user, which means either banking on the very slim chance that all your users are running PHPSuExec or similar, or making the self-installing script a PHP shell script instead of a web script and have users run it from command line, which again banks on the chance that users will have SSH access (which is a fair bet, but still not everyone does).</description>
		<content:encoded><![CDATA[<p>The only thing bad about self installing PHP web scripts is that usually you&#8217;re web root &amp; application root will have to have world-writeable permissions in order for PHP to write the files, and then once they are written, they will usually be owned by &#8220;apache&#8221;, &#8220;nobody&#8221;, or &#8220;www&#8221;, so you [your account user] won&#8217;t be able to do shit with them unless PHP sets the permissions on the new files &amp; folders as world-writable.</p>
<p>The only ways to avoid that is to run PHP as your user, which means either banking on the very slim chance that all your users are running PHPSuExec or similar, or making the self-installing script a PHP shell script instead of a web script and have users run it from command line, which again banks on the chance that users will have SSH access (which is a fair bet, but still not everyone does).</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-23325</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Tue, 16 May 2006 13:19:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-23325</guid>
		<description>&lt;blockquote&gt;
I think what’s nuts is that this is definitely not a function. This is a set of *tokens* that halts the compiler—the “__halt_compiler” token followed by a “(” token and a “)” token. It’s a reasonable bit of functionality, but it’s also yet another case of PHP being sloppy about language definition and terminology.
&lt;/blockquote&gt;

That&#039;s a fair point (evidence &lt;a href=&quot;http://lxr.php.net/source/ZendEngine2/zend_language_parser.y#168&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt;). 

&lt;blockquote&gt;
Could see a use for digitally signing scripts too.
&lt;/blockquote&gt;

Really good idea!</description>
		<content:encoded><![CDATA[<blockquote><p>
I think what’s nuts is that this is definitely not a function. This is a set of *tokens* that halts the compiler—the “__halt_compiler” token followed by a “(” token and a “)” token. It’s a reasonable bit of functionality, but it’s also yet another case of PHP being sloppy about language definition and terminology.
</p></blockquote>
<p>That&#8217;s a fair point (evidence <a href="http://lxr.php.net/source/ZendEngine2/zend_language_parser.y#168" rel="nofollow">here</a>). </p>
<blockquote><p>
Could see a use for digitally signing scripts too.
</p></blockquote>
<p>Really good idea!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: ianbicking</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22847</link>
		<dc:creator>ianbicking</dc:creator>
		<pubDate>Sat, 13 May 2006 02:51:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22847</guid>
		<description>I think what&#039;s nuts is that this is definitely not a function.  This is a set of *tokens* that halts the compiler -- the &quot;__halt_compiler&quot; token followed by a &quot;(&quot; token and a &quot;)&quot; token.  It&#039;s a reasonable bit of functionality, but it&#039;s also yet another case of PHP being sloppy about language definition and terminology.</description>
		<content:encoded><![CDATA[<p>I think what&#8217;s nuts is that this is definitely not a function.  This is a set of *tokens* that halts the compiler &#8212; the &#8220;__halt_compiler&#8221; token followed by a &#8220;(&#8221; token and a &#8220;)&#8221; token.  It&#8217;s a reasonable bit of functionality, but it&#8217;s also yet another case of PHP being sloppy about language definition and terminology.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: chrisb</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22770</link>
		<dc:creator>chrisb</dc:creator>
		<pubDate>Fri, 12 May 2006 14:47:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22770</guid>
		<description>Cheers Harry, makes a bit more sense now...  Spoilt by .net it seems ;)</description>
		<content:encoded><![CDATA[<p>Cheers Harry, makes a bit more sense now&#8230;  Spoilt by .net it seems ;)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ren</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22763</link>
		<dc:creator>Ren</dc:creator>
		<pubDate>Fri, 12 May 2006 13:40:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22763</guid>
		<description>Could see a use for digitally signing scripts too.</description>
		<content:encoded><![CDATA[<p>Could see a use for digitally signing scripts too.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22759</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Fri, 12 May 2006 13:01:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22759</guid>
		<description>&lt;blockquote&gt;
Ok, I really don&#039;t see the point of this? Granted, I’m not coming from a php background, but I can’t see much benefit from the examples you&#039;ve provided?
Is it meant to facilitate an equivalent of embedded resources or just as some strange way to install stuff?
&lt;/blockquote&gt;

Answering the last question first, this enables both - you can embed resources this way which in turn, enables stuff like building installers.

As to the point - specific to installers, in general the mission is to make life easy for end users of PHP applications and (arguable) to discourage them from doing silly things with your code (fudforum is the case in point there).

When it comes to installing a PHP application, perhaps the trickiest issue for many is setting up PHP&#039;s include paths correctly. For people writing applications, the easiest approach, to prevent giving users headaches, is to use relative paths so people can just &quot;unzip and go&quot;. Unfortunately that typically means dropping a bunch of code below the document root which really shouldn&#039;t be there (for security), in particular config files. The other issue with the &quot;unzip and go&quot; approach is you don&#039;t tend to run into problems (like missing extensions) until your application is actually running. An installer can check the environment for requirements in advance.

Arguably fudforum&#039;s installer takes things a step further in that it handles stuff like setting filesystem permissions and, in effect, actively discourages hacking. Depending on your point of view, that can be a very good thing (you know pretty much what a user has installed).

Anyway - this helps in building &quot;self installing&quot; PHP scripts.</description>
		<content:encoded><![CDATA[<blockquote><p>
Ok, I really don&#8217;t see the point of this? Granted, I’m not coming from a php background, but I can’t see much benefit from the examples you&#8217;ve provided?<br />
Is it meant to facilitate an equivalent of embedded resources or just as some strange way to install stuff?
</p></blockquote>
<p>Answering the last question first, this enables both &#8211; you can embed resources this way which in turn, enables stuff like building installers.</p>
<p>As to the point &#8211; specific to installers, in general the mission is to make life easy for end users of PHP applications and (arguable) to discourage them from doing silly things with your code (fudforum is the case in point there).</p>
<p>When it comes to installing a PHP application, perhaps the trickiest issue for many is setting up PHP&#8217;s include paths correctly. For people writing applications, the easiest approach, to prevent giving users headaches, is to use relative paths so people can just &#8220;unzip and go&#8221;. Unfortunately that typically means dropping a bunch of code below the document root which really shouldn&#8217;t be there (for security), in particular config files. The other issue with the &#8220;unzip and go&#8221; approach is you don&#8217;t tend to run into problems (like missing extensions) until your application is actually running. An installer can check the environment for requirements in advance.</p>
<p>Arguably fudforum&#8217;s installer takes things a step further in that it handles stuff like setting filesystem permissions and, in effect, actively discourages hacking. Depending on your point of view, that can be a very good thing (you know pretty much what a user has installed).</p>
<p>Anyway &#8211; this helps in building &#8220;self installing&#8221; PHP scripts.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: chrisb</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22755</link>
		<dc:creator>chrisb</dc:creator>
		<pubDate>Fri, 12 May 2006 12:10:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22755</guid>
		<description>Ok, I really don&#039;t see the point of this?  Granted, I&#039;m not coming from a php background, but I can&#039;t see much benefit from the examples you&#039;ve provided?  Is it meant to facilitate an equivalent of embedded resources or just as some strange way to install stuff?</description>
		<content:encoded><![CDATA[<p>Ok, I really don&#8217;t see the point of this?  Granted, I&#8217;m not coming from a php background, but I can&#8217;t see much benefit from the examples you&#8217;ve provided?  Is it meant to facilitate an equivalent of embedded resources or just as some strange way to install stuff?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22727</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Fri, 12 May 2006 07:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22727</guid>
		<description>&lt;blockquote&gt;
P.S.—No &#039;a&#039; in my last name, &#039;kay thanks
&lt;/blockquote&gt;

Whoops - fixed. Got it right &lt;a href=&quot;http://www.sitepoint.com/blogs/2004/05/04/messing-with-peclcvsclient/&quot; rel=&quot;nofollow&quot;&gt;last time&lt;/a&gt; - 1 in 2 hit rate.</description>
		<content:encoded><![CDATA[<blockquote><p>
P.S.—No &#8216;a&#8217; in my last name, &#8216;kay thanks
</p></blockquote>
<p>Whoops &#8211; fixed. Got it right <a href="http://www.sitepoint.com/blogs/2004/05/04/messing-with-peclcvsclient/" rel="nofollow">last time</a> &#8211; 1 in 2 hit rate.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Sara Golemon</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22694</link>
		<dc:creator>Sara Golemon</dc:creator>
		<pubDate>Fri, 12 May 2006 02:38:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22694</guid>
		<description>Not nuts.

__halt_compiler does exactly what it says, it HALTS the compiler, which means that it doesn&#039;t have to load the entire contents of the file into memory.

Non script data (e.g. inline HTML) is duped and droped into a ZEND_ECHO op so that it can be displayed when script execution reaches that point.  If your script simply issues a die/exit, then you&#039;ve copied that stuff into memory for NO REASON.  Now apply this to a multi-megabyte script designed to be run in place (rather than executed once at the command line.  Feeling wasteful yet?

Add in the fact that that __halt_compiler will populated a magic constant with the boundary of where your code stops and your data begins and suddenly you&#039;re saving the cost of having to look for that delimiter the hard (read: slow, memory expensive) way.

P.S. - No &#039;a&#039; in my last name, &#039;kay thanks.</description>
		<content:encoded><![CDATA[<p>Not nuts.</p>
<p>__halt_compiler does exactly what it says, it HALTS the compiler, which means that it doesn&#8217;t have to load the entire contents of the file into memory.</p>
<p>Non script data (e.g. inline HTML) is duped and droped into a ZEND_ECHO op so that it can be displayed when script execution reaches that point.  If your script simply issues a die/exit, then you&#8217;ve copied that stuff into memory for NO REASON.  Now apply this to a multi-megabyte script designed to be run in place (rather than executed once at the command line.  Feeling wasteful yet?</p>
<p>Add in the fact that that __halt_compiler will populated a magic constant with the boundary of where your code stops and your data begins and suddenly you&#8217;re saving the cost of having to look for that delimiter the hard (read: slow, memory expensive) way.</p>
<p>P.S. &#8211; No &#8216;a&#8217; in my last name, &#8216;kay thanks.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Greg Beaver</title>
		<link>http://www.sitepoint.com/blogs/2006/05/12/__halt_compiler-how-nuts/comment-page-1/#comment-22684</link>
		<dc:creator>Greg Beaver</dc:creator>
		<pubDate>Fri, 12 May 2006 01:10:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.sitepoint.com/blogs/?p=1534#comment-22684</guid>
		<description>see http://pear.php.net/install-pear-nozlib.phar

If you have uncompressed data, the parser will die if it encounters duplicate classes (as it should).  As such, you can&#039;t include a tarball for PEAR and use PEAR to install it without __HALT_COMPILER();

Hardly nuts.

base64decode() is also noticeably slower.  running install-pear-nozlib.phar is literally just as fast as running the install-pear.php that it is based on, and this is with tons of code.  Definitely a good thing.</description>
		<content:encoded><![CDATA[<p>see <a href="http://pear.php.net/install-pear-nozlib.phar" rel="nofollow">http://pear.php.net/install-pear-nozlib.phar</a></p>
<p>If you have uncompressed data, the parser will die if it encounters duplicate classes (as it should).  As such, you can&#8217;t include a tarball for PEAR and use PEAR to install it without __HALT_COMPILER();</p>
<p>Hardly nuts.</p>
<p>base64decode() is also noticeably slower.  running install-pear-nozlib.phar is literally just as fast as running the install-pear.php that it is based on, and this is with tons of code.  Definitely a good thing.</p>]]></content:encoded>
	</item>
</channel>
</rss>
