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

<channel>
	<title>Add It Up Development Blog &#187; PHP</title>
	<atom:link href="http://blog.letsadditup.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.letsadditup.com</link>
	<description>Building a PHP financial management app, one line of code at a time</description>
	<pubDate>Thu, 11 Dec 2008 12:50:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>To Parse or not to Parse, that is the question</title>
		<link>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/</link>
		<comments>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 19:20:04 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[CodeIgniter]]></category>

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

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

		<category><![CDATA[Add new tag]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=17</guid>
		<description><![CDATA[When I first began to consider building a web application using CodeIgniter, one of the key aspects I had in my mind was to keep the HTML template files (the View in Model-View-Controller) as PHP-free as humanly possible.
At that time, I was planning to develop an e-commerce application (this was before the launch of Magento), [...]]]></description>
			<content:encoded><![CDATA[<p>When I first began to consider building a web application using <a href="http://codeigniter.com">CodeIgniter</a>, one of the key aspects I had in my mind was to keep the HTML template files (the View in <a href="en.wikipedia.org/wiki/Model-view-controller">Model-View-Controller</a>) as PHP-free as humanly possible.</p>
<p>At that time, I was planning to develop an e-commerce application (this was before the launch of <a href="http://www.magentocommerce.com/">Magento</a>), so my reasoning was that a distributed web app should make it easy for programmers to work on backend code while allowing designers to hack on the templates without having to understand a bunch of complicated PHP statements.</p>
<h3>CodeIgniter&#8217;s Template Parser Class</h3>
<p>To pass data from the Controller to the View in CodeIgniter, you would normally load the view template and pass in an array of data:</p>
<pre>$this-&gt;load-&gt;view('my_template', array(</pre>
<pre>    'page_name' =&gt; 'About Us',</pre>
<pre>    'page_content' =&gt; 'Hey, we are a great company!'</pre>
<pre>));</pre>
<p>The array of data is transformed into local variables for use within the template:</p>
<pre>&lt;h1&gt;&lt;?= $page_name ?&gt;&lt;/h1&gt;</pre>
<pre>&lt;p&gt;&lt;?= $page_content ?&gt;&lt;/p&gt;</pre>
<p>That&#8217;s all very well with basic variables, but when it comes to arrays your template can quickly become cluttered with nested if, else, and foreach statements - and that can be confusing for non-technical designers or purely front-end (HTML/CSS) developers.</p>
<p>The <a title="The Parser Class on the CI user guide" href="http://codeigniter.com/user_guide/libraries/parser.html">Template Parser Class</a> replaces those PHP echo statements with special variables that, in theory, are easier to understand:</p>
<pre>&lt;h1&gt;{page_title}&lt;/h1&gt;</pre>
<pre>&lt;p&gt;{page_content}&lt;/p&gt;</pre>
<pre>&lt;ul&gt;</pre>
<pre>    {link_list}</pre>
<pre>        &lt;li&gt;{link_description}&lt;/li&gt;</pre>
<pre>    {/link_list}</pre>
<pre>&lt;/ul&gt;</pre>
<p>For simple strings and basic arrays, the Parser class is easy to use - but once you start wanting to use different HTML depending on the values of your data, it can get messy. With embedded PHP in the templates, it is easy to throw a little logic into the View file - if it&#8217;s this then add that class name - but following a strict &#8220;No PHP&#8221; rule can have you jumping through hoops if your HTML isn&#8217;t architected to cope with displaying different types of data in the same way.</p>
<p>Of course, the whole point of MVC is that you <em>shouldn&#8217;t</em> be putting logic in your Views, so there really shouldn&#8217;t be any major hurdles in solely using the Parser class - but it&#8217;s going to take me a little while to get used to thinking that way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/07/12/to-parse-or-not-to-parse-that-is-the-question/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is PHP4 worth it any more?</title>
		<link>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/</link>
		<comments>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 15:04:18 +0000</pubDate>
		<dc:creator>Matthew Pennell</dc:creator>
		
		<category><![CDATA[Decisions]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://blog.letsadditup.com/?p=4</guid>
		<description><![CDATA[A week or so ago, I posed a question on Twitter:
If you were going to build a PHP application for use by others, would you even bother making it PHP4 compatible any more?
Responses were - with one exception - unanimous, with most people citing hosting as a key reason. Rachel Andrew, edgeofmyseat:
PHP5 all the way [...]]]></description>
			<content:encoded><![CDATA[<p>A week or so ago, <a href="http://twitter.com/matthewpennell/statuses/844042373">I posed a question</a> on Twitter:</p>
<blockquote><p>If you were going to build a PHP application for use by others, would you even bother making it PHP4 compatible any more?</p></blockquote>
<p>Responses were - with <a title="Kerri Hicks disagreed" href="http://twitter.com/kerri9494/statuses/844046820">one exception</a> - unanimous, with most people citing hosting as a key reason. <a href="http://edgeofmyseat.com/">Rachel Andrew, edgeofmyseat</a>:</p>
<blockquote><p>PHP5 all the way &#8230; more apps that require PHP5 means more people asking for PHP5 on shared hosting.</p></blockquote>
<p><a href="http://dotjay.co.uk/">Jon Gibbins</a> agreed:</p>
<blockquote><p>Not worth the effort now I think. I suspect many hosting services to be upgrading now that PHP 4 is end of life.</p></blockquote>
<p>And <a href="http://www.studio24.net/">Simon Jones, studio24</a>:</p>
<blockquote><p>Encourage people to look forward not back.</p></blockquote>
<h3>CodeIgniter and PHP5</h3>
<p>While there are a fair few PHP frameworks that only run on PHP5, <a href="http://www.codeigniter.com/">CodeIgniter</a> is not one of them - in fact, the only minor benefit one can obtain from using PHP5 is that it allows you to chain methods together when using its <a href="http://codeigniter.com/user_guide/database/active_record.html">Active Record class</a>:</p>
<pre>$result = $this-&gt;db-&gt;select('id, name')-&gt;from('mytable')-&gt;where('name', 'Bob')-&gt;get();</pre>
<p>So no real benefit to be gained in that respect. What PHP5 does offer, though, is <a title="List of new PHP5 functions on php.net" href="http://www.php.net/manual/en/migration5.functions.php">many new functions</a>, a completely <a href="http://www.php.net/manual/en/language.oop5.php">new object model</a>, and various other <a title="Overloading in PHP5" href="http://http://uk.php.net/manual/en/language.oop5.overloading.php">cool</a> <a href="http://uk3.php.net/manual/en/ref.filter.php">things</a>.</p>
<p>At the moment I&#8217;m leaning heavily in favour of going with PHP5 - as someone else noted, it&#8217;s going to be much easier to port code from PHP5 to PHP6, than from 4 to 6 - but I&#8217;m still open to persuasion if anyone thinks differently.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.letsadditup.com/2008/07/07/is-php4-worth-it-any-more/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
