<?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/"
	>

<channel>
	<title>DomainFunk.com &#187; Scripting</title>
	<atom:link href="http://domainfunk.com/generalsections/all-about-web-scripts/feed" rel="self" type="application/rss+xml" />
	<link>http://domainfunk.com</link>
	<description>A Magazine for webconnoissuers</description>
	<pubDate>Fri, 31 Jul 2009 08:31:59 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Parsing XML: XML to HTML using PHP!</title>
		<link>http://domainfunk.com/parsing-xml-xml-to-html-using-php</link>
		<comments>http://domainfunk.com/parsing-xml-xml-to-html-using-php#comments</comments>
		<pubDate>Fri, 31 Jul 2009 08:31:59 +0000</pubDate>
		<dc:creator>DomainFunk.com</dc:creator>
		
		<category><![CDATA[How-To's]]></category>

		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[Parsing XML]]></category>

		<category><![CDATA[PHP XML Parser Simple]]></category>

		<category><![CDATA[XML to HTML]]></category>

		<category><![CDATA[XML to HTML file]]></category>

		<guid isPermaLink="false">http://domainfunk.com/?p=299</guid>
		<description><![CDATA[  Lately I just finished scripting a nice little system that randomizes and publishes content based on an XML feed provided by partner content sponsor. While doing some research for this, I came to know I wasn&#8217;t the lone one who wanted to install such a system. The web app, for which I wrote [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:right'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://domainfunk.com/parsing-xml-xml-to-html-using-php&amp;t=Parsing+XML%3A+XML+to+HTML+using+PHP%21&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://domainfunk.com/parsing-xml-xml-to-html-using-php&amp;title=Parsing+XML%3A+XML+to+HTML+using+PHP%21&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td></table></div><p>Lately I just finished scripting a nice little system that randomizes and publishes content based on an XML feed provided by partner content sponsor. While doing some research for this, I came to know I wasn&#8217;t the lone one who wanted to install such a system. The web app, for which I wrote this system, runs a script every week creating new .html files from an XML content feed and keeps creating these plain .HTML files on the fly, in essence growing my content library every week <img src='http://domainfunk.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope this comes in hand to you guys out there looking for this.</p>
<h1>The Simple Parser</h1>
<p>I needed a simple parser which would not need XSLT and the size of the parser would remain small. Since the parser would be placed as a cron job, I needed it to be simple and without the complexities of XSLT. So here is part of the code that made the parser worked.<br />
<code><br />
&lt;?php</code></p>
<p>$doc = new DOMDocument(); //We create a new DOM object.<br />
$doc-&gt;load(&#8217;samplefeed.xml&#8217;,LIBXML_DTDLOAD|LIBXML_DTDATTR); //load all elements of the XML feed. Using LIBXML_DTDLOAD we  load external subset and use LIBXML_DTDATTR to set the default DTD attributes, both are <a title="PHP Lib XML constants" href="http://www.w3schools.com/php/php_ref_libxml.asp" target="_blank">PHP Lib XML constants.</a><br />
$contentitems = $doc-&gt;getElementsByTagName( &#8220;books&#8221; ); // we are now fetching the elements, and with this statement fetching all elements enclosed within the &lt;books&gt; tags.</p>
<p>foreach($contentitems as $contentitem)<br />
{</p>
<p>$titles = $contentitem-&gt;getElementsByTagName( &#8220;title&#8221; );<br />
$title = $titles-&gt;item(0)-&gt;nodeValue; //we are not taking the values from each element nodes.</p>
<p>$authors = $metadata-&gt;getElementsByTagName( &#8220;byline&#8221; );<br />
$author = $authors-&gt;item(0)-&gt;nodeValue;</p>
<p>$ISBNS = $metadata-&gt;getElementsByTagName( &#8220;isbn&#8221; );<br />
$ISBN = $ISBNS-&gt;item(0)-&gt;nodeValue;</p>
<p>//below we are starting an HTML file and using a PHP variable to hold it.</p>
<p>$html = &#8216;&lt;html&gt;</p>
<p>&lt;!&#8211; html code can come in here &#8211;&gt;&#8217;;</p>
<p>/*main article starts here */</p>
<p>$html = $html.$title.&#8221;&lt;br/&gt;&#8221;;<br />
$html = $html.$author.&#8221;&lt;br/&gt;&#8221;;<br />
$html = $html.$ISBN.&#8221;&lt;br/&gt;&#8221;;</p>
<p>$html =&#8217;<br />
/*footer part of the html page */<br />
&lt;/html&gt;&#8217;;</p>
<p>$ourFileName = &#8220;feedarticles/&#8221;.trim($title).&#8221;.html&#8221;; //keeping the title the same as<br />
$ourFileName = str_ireplace(&#8221;?&#8221;,&#8221;",$ourFileName); //removing characters that get attached during char-set conversions or shall we say non-conversions.<br />
$ourFileName = str_ireplace(&#8221;_&#8221;,&#8221;",$ourFileName);<br />
$ourFileName = str_ireplace(&#8221;:&#8221;,&#8221;",$ourFileName);<br />
$ourFileName = str_ireplace(&#8221;;&#8221;,&#8221;",$ourFileName);<br />
$ourFileName = str_ireplace(&#8221;&#8216;&#8221;,&#8221;",$ourFileName);</p>
<p>echo $ourFileName.&#8221; creating the file &#8220;; //Just echoing the statement while creating the file.<br />
$ourFileHandle = fopen($ourFileName, &#8216;w&#8217;) or die(&#8221;can&#8217;t open file&#8221;); //init the file handle<br />
fwrite($ourFileHandle, $html);//write the file.<br />
fclose($ourFileHandle);//close the file handle.</p>
<p>}</p>
<p>?&gt;</p>
<h1>The XML Page</h1>
<p>The below is the SampleFeed.xml file, with the fields that will be parsed.</p>
<p>&lt;NewDataSet _xmlns3a_xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;&gt;</p>
<p>&lt;Books&gt;<br />
&lt;title&gt;Java Server Pages&lt;/title&gt;<br />
&lt;author&gt;SAMS&lt;/author&gt;<br />
&lt;ISBN&gt;1234&lt;/ISBN&gt;</p>
<p>&lt;title&gt;Logistics&lt;/title&gt;<br />
&lt;author&gt;Tata Mcgraw Hil&lt;/author&gt;<br />
&lt;ISBN&gt;5678&lt;/ISBN&gt;</p>
<p>&lt;/books&gt;<br />
&lt;/NewDataSet&gt;</p>
<h1>Note</h1>
<p>Albeit, there are better and newer ways of parsing XML using PHP, this was suitable for me, because its pretty simple code <img src='http://domainfunk.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> and it works wonders!</p>
<h1>Resources</h1>
<p>Here are both files zipped up, make sure the permissions are setup right for directories that you want to user write these files into. Here is the entire <a title="Simple XML Parser " href="http://domainfunk.com/articlesuploads/SimpleXMLParse.zip" target="_blank">Simple XML Parser</a> zip, that creates .html files from XML feeds.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Enjoyed it? Share it!:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;bodytext=Lately%20I%20just%20finished%20scripting%20a%20nice%20little%20system%20that%20randomizes%20and%20publishes%20content%20based%20on%20an%20XML%20feed%20provided%20by%20partner%20content%20sponsor.%20While%20doing%20some%20research%20for%20this%2C%20I%20came%20to%20know%20I%20wasn%27t%20the%20lone%20one%20who%20wanted%20to%20install%20such%20" title="Digg"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;annotation=Lately%20I%20just%20finished%20scripting%20a%20nice%20little%20system%20that%20randomizes%20and%20publishes%20content%20based%20on%20an%20XML%20feed%20provided%20by%20partner%20content%20sponsor.%20While%20doing%20some%20research%20for%20this%2C%20I%20came%20to%20know%20I%20wasn%27t%20the%20lone%20one%20who%20wanted%20to%20install%20such%20" title="Google Bookmarks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;notes=Lately%20I%20just%20finished%20scripting%20a%20nice%20little%20system%20that%20randomizes%20and%20publishes%20content%20based%20on%20an%20XML%20feed%20provided%20by%20partner%20content%20sponsor.%20While%20doing%20some%20research%20for%20this%2C%20I%20came%20to%20know%20I%20wasn%27t%20the%20lone%20one%20who%20wanted%20to%20install%20such%20" title="del.icio.us"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="TwitThis"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;t=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Facebook"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php" title="Technorati"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="StumbleUpon"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;body=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php" title="E-mail this story to a friend!"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;source=DomainFunk.com+A+Magazine+for+webconnoissuers&amp;summary=Lately%20I%20just%20finished%20scripting%20a%20nice%20little%20system%20that%20randomizes%20and%20publishes%20content%20based%20on%20an%20XML%20feed%20provided%20by%20partner%20content%20sponsor.%20While%20doing%20some%20research%20for%20this%2C%20I%20came%20to%20know%20I%20wasn%27t%20the%20lone%20one%20who%20wanted%20to%20install%20such%20" title="LinkedIn"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Live"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Ma.gnolia"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Ma.gnolia" alt="Ma.gnolia" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;t=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="MySpace"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;submitHeadline=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;submitSummary=Lately%20I%20just%20finished%20scripting%20a%20nice%20little%20system%20that%20randomizes%20and%20publishes%20content%20based%20on%20an%20XML%20feed%20provided%20by%20partner%20content%20sponsor.%20While%20doing%20some%20research%20for%20this%2C%20I%20came%20to%20know%20I%20wasn%27t%20the%20lone%20one%20who%20wanted%20to%20install%20such%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://yigg.de/neu?exturl=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;exttitle=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Yigg"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Sphinn"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Mixx"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="blogmarks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21&amp;url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php" title="blogtercimlap"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Book.mark.hu"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Book.mark.hu" alt="Book.mark.hu" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://co.mments.com/track?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="co.mments"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/co.mments.png" title="co.mments" alt="co.mments" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="De.lirio.us"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="De.lirio.us" alt="De.lirio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="DotNetKicks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkagogo.com/go/AddNoPopup?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="LinkaGoGo"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/linkagogo.png" title="LinkaGoGo" alt="LinkaGoGo" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;h=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="NewsVine"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fdomainfunk.com%2Fparsing-xml-xml-to-html-using-php&amp;title=Parsing%20XML%3A%20XML%20to%20HTML%20using%20PHP%21" title="Reddit"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="scuttle"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="scuttle" alt="scuttle" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Spurl"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" target="_blank" href="" title="YahooMyWeb"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://domainfunk.com/parsing-xml-xml-to-html-using-php/feed</wfw:commentRss>
		</item>
		<item>
		<title>Uncorking PHP Performance</title>
		<link>http://domainfunk.com/uncorking-php-performance</link>
		<comments>http://domainfunk.com/uncorking-php-performance#comments</comments>
		<pubDate>Mon, 01 Dec 2008 21:31:01 +0000</pubDate>
		<dc:creator>DomainFunk.com</dc:creator>
		
		<category><![CDATA[Scripting]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[php performance]]></category>

		<category><![CDATA[php scripting]]></category>

		<category><![CDATA[php webscripting]]></category>

		<category><![CDATA[web scripts optimization]]></category>

		<guid isPermaLink="false">http://domainfunk.com/?p=107</guid>
		<description><![CDATA[  Its been quite a long time since PHP has been around and It is still gaining a major share of the web where web application and web site development is concerned. With more and more Developers and Web Masters using PHP as their preferred scripting language, it only makes sense to shed some [...]]]></description>
			<content:encoded><![CDATA[<!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	--><div style='float:right'><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://domainfunk.com/uncorking-php-performance&amp;t=Uncorking+PHP+Performance&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td> <td><iframe src='http://www.reddit.com/button_content?newwindow=1&amp;url=http://domainfunk.com/uncorking-php-performance&amp;title=Uncorking+PHP+Performance&amp;t=2 ' height='80' width='52' scrolling='no' frameborder='0' ></iframe></td></table></div><p><a href="http://domainfunk.com/uncorking-php-performance"><img src="http://domainfunk.com/wp-content/uploads/2008/12/phpperfo2.png" alt="" title="phpperfo2" width="190" height="190" class="alignleft size-medium wp-image-110" /></a>Its been quite a long time since PHP has been around and It is still gaining a major share of the web where web application and web site development is concerned. With more and more Developers and Web Masters using PHP as their preferred scripting language, it only makes sense to shed some light, as a trail blazer, to uncorking PHP performance. If you would like your PHP scripts to run at least thirty percent faster, here’s to you.</p>
<p>Most Microsoft and Other Scripting language adopting diehards, have always pointed out the fact that as your scripts keep building up and your web site or web applications keep getting more and more complex day by day, PHP loses ground and starts becoming slower. Now, the flip side of this debate would be; if the above mentioned statement would have been correct, then, why would Yahoo be using PHP, eh? </p>
<p>Yes, Many websites and Biggies, use PHP. Not only because its open source, but also because it is scalable and flexible and performance, today is no more an issue; provided ones know what is required to squeeze every last nana second out of your compile time, fetch time, etc to optimize your scripts and web applications. As compared to its counter parts like the .net Platform, JSP, etc. it only falls cheaper in terms real dollars to adopt PHP; not that we have anything against these languages, but we too like others are searching for an easier, flexible and scalable Web Scripting Mecca.</p>
<p>If done right, complex PHP scripts could be blazing fast. Where most intermidiate PHP based web applications, running into thousands of lines of code, it only goes to show the efficiency of the design and implementation of the Zend Engine that makes PHP tick.</p>
<h1>Factors affecting PHP Performance</h1>
<p>Increasing your PHP Performance, is not making your scripts run faster, but a set off between scalibility and speed. An, unruly, large number of factors influence the performance of a web application or a website. These factors include, in no sequence, database schemas, database performance, server configurations, web application design, and implementation of your web application scripts. We are going to assume that you would have already hammered down the above list, where performance is concerned. So, that leaves the bottlenecks in code and compilation time of your scripts.</p>
<h1>So, how exactly can you uncork bottlenecks where PHP performanace is concerned?</h1>
<p>The best place to start optimizing for PHP performance would be profiling or commonly known as PHP performance profiling. </p>
<h1>What does PHP performance profiling mean?</h1>
<p>Well, according to the Law of Ahmdahl, you cannot put racing tires on a tuk-tuk and expect to burn the road. Direct relation to above law with PHP would only indicate that we need to look at things that are obivious while reviewing your PHP code and Identifying potential bottlenecks. PHP performance profiling, thence, means simply to identify bottlenecks that affect PHP performance and then uncorking these performance bottlenecks.</p>
<h1>Great, So whats up doc…?</h1>
<p>First step to PHP performance profiling would require you to start looking for such bottlenecks. Which means that you would require information about how your PHP script performs in relation to web browsers and databases. PHP performance profiling, does eventually lead up to running your PHP scripts within a controlled environment, with the environment providing such information to identify bottlenecks affecting PHP performance. </p>
<h1>Performance Profiling tools.</h1>
<p>A vast number of tools are available for free, for profiling the performance of your PHP scripts. Some of the most widely used ones include Xdebug, APD, also known as Advanced PHP Debugger, Benchmark, DBG, etc. [List of tools given in resources section below with links]</p>
<p>Selecting a tool from the list, involves asking yourself a question. How serious are you about squeezing every ounce of the cycle out of the code? Depending on the answer, you could either use one single profiler or a multiple of them to detect and compare bottlenecks. All these PHP performance profiling tools, work in different manner and make available different information about your PHP script execution. The most commonly used of the lot being Xdebug and APD.</p>
<h1>Got the corks, where’s the cork screw – PHP opcode optimization?</h1>
<p>So, you have identified certain bottlenecks and simplified your code further, where ever required to increase your PHP performance. So whats the next step to PHP performance?</p>
<p>The next step would definitely be optimizing your op code. In normal circumstances your PHP scripts are compiled into Zend Opcodes by the PHP Zend Engine. This Opcode is then excuted, resulting in the formation of an HTML page and this HTML page is what is sent to the browser. </p>
<p>Once the HTML page is sent to the browser, the opcodes are flushed from the memory. That is, the opcodes are cleared from the memory after they have been excuted by the webserver. </p>
<h1>PHP Opcodes… scratch… scratch… scratch..?</h1>
<p>Opcodes or Operation codes are binary low level instructions or instruction sets. The PHP opcodes, generated by the Zen Engine can, today, be further optimized using the Zend Optimizer. By just using the Zend optimizer, you can increaser the performance of your PHP scripts, anywhere from, 30-50%. The optimized PHP opcodes, further can be cached. If cached, the PHP opcode after execution is never flushed, thus if the same PHP script/PHP ebpage was to be requested by the browser, the Zend Engine wouldn’t have to compile the script, because the PHP opcode would have been precompiled, optimized and cached! Have a look at the flow chart diagram.</p>
<p><a href="http://domainfunk.com/uncorking-php-performance"><img src="http://domainfunk.com/wp-content/uploads/2008/12/phpperfo1.gif" alt="" title="phpperfo1" width="500" height="333" class="aligncenter size-full wp-image-108" /></a></p>
<p>PHP opcode caching can further increase PHP performance form 40-200%.</p>
<h1>PHP Performance Resources</h1>
<p>PHP@ www.php.net<br />
MySQL@ MySQL.com<br />
Zend Engine, Zend Optimizer and Zend Accelerator@ www.zend.com<br />
Benchmark(A PEAR Project)@ http://pear.php.net/benchmark<br />
DBG@ http://dd.cron.ru/dbg<br />
Xdebug@ http://xdebug.derickrethans.nl/<br />
Advanced PHP Debugger@ http://pear.php.net/apd<br />
eAccelerator@ http://eaccelerator.net/HomeUk/<br />
Alternative PHP cache or APC@ http://apc.communityconnect.com/<br />
PHP Accelerator@ http://www.php-accelerator.co.uk/<br />
AfterBurner Cache@ http://www.bwcache.bware.it/<br />
Further reading@ http://phplens.com/lens/php-book/optimizing-debugging-php.php</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Enjoyed it? Share it!:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow" target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance&amp;bodytext=Its%20been%20quite%20a%20long%20time%20since%20PHP%20has%20been%20around%20and%20It%20is%20still%20gaining%20a%20major%20share%20of%20the%20web%20where%20web%20application%20and%20web%20site%20development%20is%20concerned.%20With%20more%20and%20more%20Developers%20and%20Web%20Masters%20using%20PHP%20as%20their%20preferred%20scripting%20la" title="Digg"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance&amp;annotation=Its%20been%20quite%20a%20long%20time%20since%20PHP%20has%20been%20around%20and%20It%20is%20still%20gaining%20a%20major%20share%20of%20the%20web%20where%20web%20application%20and%20web%20site%20development%20is%20concerned.%20With%20more%20and%20more%20Developers%20and%20Web%20Masters%20using%20PHP%20as%20their%20preferred%20scripting%20la" title="Google Bookmarks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance&amp;notes=Its%20been%20quite%20a%20long%20time%20since%20PHP%20has%20been%20around%20and%20It%20is%20still%20gaining%20a%20major%20share%20of%20the%20web%20where%20web%20application%20and%20web%20site%20development%20is%20concerned.%20With%20more%20and%20more%20Developers%20and%20Web%20Masters%20using%20PHP%20as%20their%20preferred%20scripting%20la" title="del.icio.us"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="TwitThis"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;t=Uncorking%20PHP%20Performance" title="Facebook"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://technorati.com/faves?add=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance" title="Technorati"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="StumbleUpon"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/stumbleupon.png" title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="mailto:?subject=Uncorking%20PHP%20Performance&amp;body=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance" title="E-mail this story to a friend!"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/email_link.png" title="E-mail this story to a friend!" alt="E-mail this story to a friend!" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance&amp;source=DomainFunk.com+A+Magazine+for+webconnoissuers&amp;summary=Its%20been%20quite%20a%20long%20time%20since%20PHP%20has%20been%20around%20and%20It%20is%20still%20gaining%20a%20major%20share%20of%20the%20web%20where%20web%20application%20and%20web%20site%20development%20is%20concerned.%20With%20more%20and%20more%20Developers%20and%20Web%20Masters%20using%20PHP%20as%20their%20preferred%20scripting%20la" title="LinkedIn"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="Live"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/live.png" title="Live" alt="Live" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Ma.gnolia"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Ma.gnolia" alt="Ma.gnolia" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.myspace.com/Modules/PostTo/Pages/?u=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;t=Uncorking%20PHP%20Performance" title="MySpace"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/myspace.png" title="MySpace" alt="MySpace" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;submitHeadline=Uncorking%20PHP%20Performance&amp;submitSummary=Its%20been%20quite%20a%20long%20time%20since%20PHP%20has%20been%20around%20and%20It%20is%20still%20gaining%20a%20major%20share%20of%20the%20web%20where%20web%20application%20and%20web%20site%20development%20is%20concerned.%20With%20more%20and%20more%20Developers%20and%20Web%20Masters%20using%20PHP%20as%20their%20preferred%20scripting%20la&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://yigg.de/neu?exturl=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;exttitle=Uncorking%20PHP%20Performance" title="Yigg"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/yiggit.png" title="Yigg" alt="Yigg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="Sphinn"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="Mixx"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="blogmarks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/blogmarks.png" title="blogmarks" alt="blogmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Uncorking%20PHP%20Performance&amp;url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance" title="blogtercimlap"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Book.mark.hu"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Book.mark.hu" alt="Book.mark.hu" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://co.mments.com/track?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="co.mments"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/co.mments.png" title="co.mments" alt="co.mments" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="De.lirio.us"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="De.lirio.us" alt="De.lirio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.dotnetkicks.com/kick/?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="DotNetKicks"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/dotnetkicks.png" title="DotNetKicks" alt="DotNetKicks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.linkagogo.com/go/AddNoPopup?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="LinkaGoGo"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/linkagogo.png" title="LinkaGoGo" alt="LinkaGoGo" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://www.newsvine.com/_tools/seed&amp;save?u=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;h=Uncorking%20PHP%20Performance" title="NewsVine"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/newsvine.png" title="NewsVine" alt="NewsVine" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fdomainfunk.com%2Funcorking-php-performance&amp;title=Uncorking%20PHP%20Performance" title="Reddit"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="scuttle"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="scuttle" alt="scuttle" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" target="_blank" href="" title="Spurl"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="Spurl" alt="Spurl" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow" target="_blank" href="" title="YahooMyWeb"><img src="http://domainfunk.com/wp-content/plugins/sociable/images/" title="YahooMyWeb" alt="YahooMyWeb" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://domainfunk.com/uncorking-php-performance/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
