<?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"
	>
<channel>
	<title>Comments on: Python __name__ == __main__ in PHP</title>
	<atom:link href="http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/</link>
	<description></description>
	<pubDate>Thu, 28 Aug 2008 13:59:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: SitePoint Blogs &#187; PHP Server API Differences</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-10633</link>
		<dc:creator>SitePoint Blogs &#187; PHP Server API Differences</dc:creator>
		<pubDate>Wed, 09 Nov 2005 10:53:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-10633</guid>
		<description>[...] The link doesn&#8217;t quite raise the full story though. As I remember, with PHP as a CGI under Apache, $_SERVER[&#8217;SCRIPT_FILENAME&#8217;] is the path to the CGI executable, not the script it is executing&#8212;that relates to a request for a PHP constant called __MAIN__ to identify the script where execution began. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] The link doesn&#8217;t quite raise the full story though. As I remember, with PHP as a CGI under Apache, $_SERVER[&#8217;SCRIPT_FILENAME&#8217;] is the path to the CGI executable, not the script it is executing&#8212;that relates to a request for a PHP constant called __MAIN__ to identify the script where execution began. [&#8230;]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: cagrET</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-245</link>
		<dc:creator>cagrET</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-245</guid>
		<description>&lt;p&gt;There is an another solution:&lt;/p&gt;

&lt;code lang="php"&gt;
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {
    // ...
}&lt;/code&gt;&lt;p&gt;&lt;br /&gt;
It only requires that the included file has an unique name.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>There is an another solution:</p>
<p><code lang="php">
if (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {
    // ...
}</code>
</p><p>
It only requires that the included file has an unique name.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: cagrET</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-246</link>
		<dc:creator>cagrET</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-246</guid>
		<description>&lt;p&gt;And another one:&lt;/p&gt;

&lt;code lang="php"&gt;
if (count(debug_backtrace()) == 0) {
    echo 'SELF';
}&lt;/code&gt;&lt;p&gt;&lt;br /&gt;
But I didn't do any perfomance tests with debug_backtrace() so don't know if it is not to slow.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>And another one:</p>
<p><code lang="php">
if (count(debug_backtrace()) == 0) {
    echo 'SELF';
}</code>
</p><p>
But I didn&#8217;t do any perfomance tests with debug_backtrace() so don&#8217;t know if it is not to slow.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-247</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-247</guid>
		<description>&lt;code lang="php"&gt;
if (count(debug_backtrace()) == 0) {&lt;/code&gt;&lt;p&gt;Nice one! Think that wins the lateral thought of the day ;)&lt;/p&gt;

&lt;p&gt;Running it through &lt;a href="http://www.xdebug.org"&gt;XDebug&lt;/a&gt;, compared to the alterative;&lt;/p&gt;

&lt;code lang="php"&gt;
if ( __FILE__ == array_shift(get_included_files()) ) {&lt;/code&gt;&lt;p&gt;The results looks like;&lt;/p&gt;

&lt;code&gt;
Total Time	Avg. Time	#Calls	Function Name
0.1426506042	0.0000014265	100000	count
0.1460983753	0.0000014610	100000	debug_backtrace&lt;/code&gt;&lt;p&gt;vs.&lt;/p&gt;

&lt;code&gt;
Total Time      Avg. Time	#Calls	Function Name
0.1719875336	0.0000017199	100000	array_shift
0.1729249954	0.0000017292	100000	get_included_files&lt;/code&gt;&lt;p&gt;Looks like debug_backtrace is the winner.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p><code lang="php">
if (count(debug_backtrace()) == 0) {</code>
</p><p>Nice one! Think that wins the lateral thought of the day ;)</p>
<p>Running it through <a href="http://www.xdebug.org">XDebug</a>, compared to the alterative;</p>
<p><code lang="php">
if ( __FILE__ == array_shift(get_included_files()) ) {</code>
</p><p>The results looks like;</p>
<p><code>
Total Time	Avg. Time	#Calls	Function Name
0.1426506042	0.0000014265	100000	count
0.1460983753	0.0000014610	100000	debug_backtrace</code>
</p><p>vs.</p>
<p><code>
Total Time      Avg. Time	#Calls	Function Name
0.1719875336	0.0000017199	100000	array_shift
0.1729249954	0.0000017292	100000	get_included_files</code>
</p><p>Looks like debug_backtrace is the winner.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: gerzson</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-248</link>
		<dc:creator>gerzson</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-248</guid>
		<description>&lt;p&gt;I think is_defined() should be a typo only, but I report it.&lt;br /&gt;
The name of the desired function is defined().&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>I think is_defined() should be a typo only, but I report it.<br />
The name of the desired function is defined().</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew-J2000</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-249</link>
		<dc:creator>Andrew-J2000</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-249</guid>
		<description>&lt;p&gt;heh, Harry, we think alike.&lt;/p&gt;

&lt;p&gt;I emailed, &lt;a href="mailto:dmitry@zend.com"&gt;dmitry&lt;/a&gt; (&lt;i&gt;The developer of the Perl extension&lt;/i&gt;) earlier, about &lt;i&gt;implementing Python&lt;/i&gt; and I just found your post :p. Also a comment on zend refered to this as &lt;i&gt;'bloatware'&lt;/i&gt;, which didn't quite make sense considering its not bundled with &lt;i&gt;PHP&lt;/i&gt;. &lt;a href="http://www.zend.com/zend/comments/show_comment.php?article=php5-perl&#38;id=4887&#38;pid=4751&#38;days=10000&#38;f_id=php5-perl&#38;mode=&#38;kind=php5"&gt;http://www.zend.com/zend/comments/show_comment.php?article=php5-perl&#38;id=4887&#38;pid=4751&#38;days=10000&#38;f_id=php5-perl&#38;mode=&#38;kind=php5&lt;/a&gt;&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>heh, Harry, we think alike.</p>
<p>I emailed, <a href="mailto:dmitry@zend.com">dmitry</a> (<i>The developer of the Perl extension</i>) earlier, about <i>implementing Python</i> and I just found your post :p. Also a comment on zend refered to this as <i>&#8216;bloatware&#8217;</i>, which didn&#8217;t quite make sense considering its not bundled with <i>PHP</i>. <a href="http://www.zend.com/zend/comments/show_comment.php?article=php5-perl&amp;id=4887&amp;pid=4751&amp;days=10000&amp;f_id=php5-perl&amp;mode=&amp;kind=php5">http://www.zend.com/zend/comments/show_comment.php?article=php5-perl&amp;id=4887&amp;pid=4751&amp;days=10000&amp;f_id=php5-perl&amp;mode=&amp;kind=php5</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew-J2000</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-250</link>
		<dc:creator>Andrew-J2000</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-250</guid>
		<description>&lt;p&gt;What are your comments about the perl/python extension being &lt;i&gt;'bloatware'&lt;/i&gt;?&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>What are your comments about the perl/python extension being <i>&#8216;bloatware&#8217;</i>?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: HarryF</title>
		<link>http://www.sitepoint.com/blogs/2004/04/27/python-__name__-__main__-in-php/#comment-251</link>
		<dc:creator>HarryF</dc:creator>
		<pubDate>Wed, 31 Dec 1969 19:00:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-251</guid>
		<description>&lt;p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;br /&gt;
What are your comments about the perl/python extension being 'bloatware'?&lt;br /&gt;
&lt;/p&gt;&lt;/blockquote&gt;&lt;/p&gt;

&lt;p&gt;Well the comment "Completly useless... just bloatware" doesn't really give anything to argue against, accept to say "No it isn't". Seems more like random spam.&lt;/p&gt;

&lt;p&gt;To date I've never played with the &lt;a href="http://pecl.php.net/python"&gt;Python&lt;/a&gt; or &lt;a href="http://pecl.php.net/perl"&gt;Perl&lt;/a&gt; extensions.&lt;/p&gt;

&lt;p&gt;Where the subject of "bloat" might need examining is when it comes to the performance overhead of loading / executing external Perl/Python code.&lt;/p&gt;

&lt;p&gt;But there is most definately a value in being able to execute Perl / Python code in PHP. Just head to &lt;a href="http://www.cpan.org"&gt;CPAN&lt;/a&gt; and you have your answer. Python also has some excellent libraries.&lt;/p&gt;

&lt;p&gt;Also that this has got Dmitry's name on it suggests to me it's a serious project, Dmitry being the original author of &lt;a href="http://turck-mmcache.sourceforge.net/"&gt;Turck MMCache&lt;/a&gt; and now &lt;a href="http://www.php.net/soap"&gt;the SOAP extension&lt;/a&gt;.&lt;/p&gt;

</description>
		<content:encoded><![CDATA[<p>
<blockquote>
<p>
What are your comments about the perl/python extension being &#8216;bloatware&#8217;?
</p>
</blockquote>
</p><p>Well the comment &#8220;Completly useless&#8230; just bloatware&#8221; doesn&#8217;t really give anything to argue against, accept to say &#8220;No it isn&#8217;t&#8221;. Seems more like random spam.</p>
<p>To date I&#8217;ve never played with the <a href="http://pecl.php.net/python">Python</a> or <a href="http://pecl.php.net/perl">Perl</a> extensions.</p>
<p>Where the subject of &#8220;bloat&#8221; might need examining is when it comes to the performance overhead of loading / executing external Perl/Python code.</p>
<p>But there is most definately a value in being able to execute Perl / Python code in PHP. Just head to <a href="http://www.cpan.org">CPAN</a> and you have your answer. Python also has some excellent libraries.</p>
<p>Also that this has got Dmitry&#8217;s name on it suggests to me it&#8217;s a serious project, Dmitry being the original author of <a href="http://turck-mmcache.sourceforge.net/">Turck MMCache</a> and now <a href="http://www.php.net/soap">the SOAP extension</a>.</p>]]></content:encoded>
	</item>
</channel>
</rss>
