<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My Beloved PHP &#187; Uncategorized</title>
	<atom:link href="http://www.mybelovedphp.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mybelovedphp.com</link>
	<description>The Art of Quick &#38; Dirty Programming</description>
	<lastBuildDate>Wed, 07 Dec 2011 15:10:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Suppressing errors in PHP with control operator @</title>
		<link>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/</link>
		<comments>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/#comments</comments>
		<pubDate>Wed, 07 Dec 2011 15:08:17 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=125</guid>
		<description><![CDATA[Errors give valuable information, it&#8217;s worth paying attention to. Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can&#8217;t solve. Reading something into simpleXML that isn&#8217;t 100% validated XML, because it&#8217;s encoded in ISO-8859 instead of UTF-8. Then use the PHP one error control operator @. When [...]]]></description>
			<content:encoded><![CDATA[<p>Errors give valuable information, it&#8217;s worth paying attention to.</p>
<p>Sometimes though when parsing content from different sources you can run into errors you can prevent, or you can&#8217;t solve.</p>
<p>Reading something into simpleXML that isn&#8217;t 100% validated XML, because it&#8217;s encoded in ISO-8859 instead of UTF-8.</p>
<p>Then use the PHP one error control operator @.</p>
<blockquote><p>When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.</p></blockquote>
<p>Tha comes quite in hand in the following piece of code :</p>
<pre class="brush: php; title: ; notranslate">

$xml = @simplexml_load_file('rssfeed.xml');
</pre>
<p>No more errors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2011/12/07/suppressing-errors-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating csv content</title>
		<link>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/</link>
		<comments>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 14:50:03 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/?p=121</guid>
		<description><![CDATA[It is tempting to simply generate CSV data with writing comma-separated  array-values. Unfortunately this obvious way of doing turns out to be a bad idea. Often it seems to be working at first, but eventually you&#8217;ll be faced with annoying bugs, wrongly escaped data. Fortunately, PHP has a native function to write CSV values to [...]]]></description>
			<content:encoded><![CDATA[<p>It is tempting to simply generate CSV data with writing comma-separated  array-values.</p>
<pre class="brush: php; title: ; notranslate">
implode(&quot;,&quot;, $data_array);
</pre>
<p>Unfortunately this obvious way of doing turns out to be a bad idea. Often it seems to be working at first, but eventually you&#8217;ll be faced with annoying bugs, wrongly escaped data.</p>
<p>Fortunately, PHP has a native function to write CSV values to a file. </p>
<pre class="brush: php; title: ; notranslate">
fputcsv()
</pre>
<p>With a little trick you can use this function to write values to the screen.<br />
Use the built-in streamwrappers:</p>
<pre class="brush: php; title: ; notranslate">
 $outstream = fopen(&quot;php://output&quot;, 'w');
 fputcsv($outstream, $data_array, ',', '&quot;');
 fclose($outstream);
</pre>
<p>This will echo the data to the screen.<br />
Most people won&#8217;t know `php://output`. A pity it&#8217;s really powerful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2011/02/25/creating-csv-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP memory leak</title>
		<link>http://www.mybelovedphp.com/2007/11/28/php-memory-leak/</link>
		<comments>http://www.mybelovedphp.com/2007/11/28/php-memory-leak/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 18:39:22 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/2007/11/28/php-memory-leak/</guid>
		<description><![CDATA[Consider an RSS feed read in as an SimpleXMLobject $rss. What&#8217;s the difference between: foreach ($rss-&#62;channel as $channel) { ... } and $foo = $rss-&#62;channel; foreach ($foo as $channel) { ... } Not much you would say, the first code example is shorter and more to the point. However when putting the scripts to work, [...]]]></description>
			<content:encoded><![CDATA[<p>Consider an RSS feed read in as an SimpleXMLobject $rss.</p>
<p>What&#8217;s the difference between:</p>
<p><code>foreach ($rss-&gt;channel as $channel) {<br />
...<br />
}</code></p>
<p>and<br />
<code> $foo = $rss-&gt;channel;<br />
foreach ($foo as $channel) {<br />
...<br />
}</code></p>
<p>Not much you would say, the first code example is shorter and more to the point. However when putting the scripts to work, (with a big rss file) we&#8217;ll soon see the difference.</p>
<h5>Memory problem and a growing swap file</h5>
<p>After a while the former example is causing a lot of disk activity and you will see your swap file grow and grow, at my computer it reached the maximum of 4 GB and off course it took ages for the script to finish.</p>
<p>And all that while the maximum memory usage for a script is set to 24MB in php.ini. Should run in a 1G computer you would say.<br />
WellÂ example 2 does but example 1 does not!</p>
<p>Is seems that iterating over an object-property in a foreach loop is troubled by a memory leak.</p>
<h5>Solution</h5>
<p>Example 2 is the workaround!</p>
<h5>Conclusion</h5>
<p>PHP 5.1 until 5.2 seem to suffer from this memory leak.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2007/11/28/php-memory-leak/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Technorati Post</title>
		<link>http://www.mybelovedphp.com/2006/12/20/technorati-post/</link>
		<comments>http://www.mybelovedphp.com/2006/12/20/technorati-post/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 00:04:10 +0000</pubDate>
		<dc:creator>programmer</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mybelovedphp.com/archives/9</guid>
		<description><![CDATA[Technorati Profile No further use.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.technorati.com/claim/2jrx5kbh9" rel="me">Technorati Profile</a><br />
No further use. <img src='http://www.mybelovedphp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mybelovedphp.com/2006/12/20/technorati-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

