<?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>Zeltus</title>
	<atom:link href="http://zeltus.eu/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://zeltus.eu/blog</link>
	<description>Bill&#039;s Blog</description>
	<lastBuildDate>Sun, 05 Sep 2010 10:51:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Pre-processing with PHP</title>
		<link>http://zeltus.eu/blog/?p=219</link>
		<comments>http://zeltus.eu/blog/?p=219#comments</comments>
		<pubDate>Sun, 05 Sep 2010 10:50:14 +0000</pubDate>
		<dc:creator>zeltus</dc:creator>
				<category><![CDATA[technical]]></category>
		<category><![CDATA[addhandler]]></category>
		<category><![CDATA[addtype]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[httpd.conf]]></category>
		<category><![CDATA[mime]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zeltus.eu/blog/?p=219</guid>
		<description><![CDATA[For me, including snippets of PHP code within my web-pages has always been a given. To the extent that it sometimes comes as a surprise to me when someone asks me how to do it. Doesn&#8217;t everyone already know? What most people trip up on is expecting PHP to only operate on files with a [...]]]></description>
			<content:encoded><![CDATA[<!--Amazon_CLS_IM_START--><p>For me, including snippets of PHP code within my web-pages has always been a given. To the extent that it sometimes comes as a surprise to me when someone asks me how to do it. Doesn&#8217;t everyone already know? <img src='http://zeltus.eu/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':-D' class='wp-smiley' /> </p>
<p>What most people trip up on is expecting PHP to only operate on files with a <i>.php</i> suffix. Nothing wrong with this so far as it goes, but I prefer my web pages to have <i>.html</i> suffixes. The fact that I choose to embed chunks of PHP inside my pages needn&#8217;t be visible to the end-user. Or rather, viewer. So how do I do it?</p>
<p>Well, it couldn&#8217;t be easier, really. </p>
<p>But first, a small refresher on how PHP embeds itself into web pages anyway. I use Apache but all HTTP Server software will work in much the same way. </p>
<p>The file Apache uses as it configuration file is invariably called <i>httpd.conf</i>. It&#8217;s location may sometimes be a little obscure, dependent on what OS it is residing on &#8211; on my Red Hat servers (well CentOS, anyway!) it is found in <i>/etc/httpd/conf/</i>. Caveat: some Ubuntu distros seem to want to call the file <i>apache2.conf</i> &#8211; but you shouldn&#8217;t have much trouble figuring that out, especially if you remember that GIYF (Google Is Your Friend) <img src='http://zeltus.eu/blog/wp-includes/images/smilies/love.gif' alt=':=LUV' class='wp-smiley' /> </p>
<p>Anyway, a well-behaved PHP install will create or amend something like the following entries in said configuration file&#8230;</p>
<pre class="brush: bash;">
&lt;IfModule dir_module&gt;
    DirectoryIndex index.php index.cgi index.html index.htm
&lt;/IfModule&gt;
.
AddHandler test/html .htm .html
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
.
LoadModule php5_module libexec/apache22/libphp5.so
.
.
</pre>
<p>In brief, PHP has told Apache that</p>
<ul>
<li>accept <i>index.php</i> as a valid directory index file. It is now the same as index.html in that respect.</li>
<li>Anytime Apache processes a file with a .php suffix, use the PHP MIME-type declared as the processing agent.</li>
<li>Load in the PHP module that does all this good stuff.</li>
</ul>
<p>OK, so at this stage, a file called say, <i>example.php</i> will be correctly processed and served by Apache. But I ALL my <b>.html</b> files pre-processed by PHP. Simples.</p>
<pre class="brush: bash;">
AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php-source .phps
</pre>
<p>After saving these changes, checking no silly typos were accidentally entered into the config file&#8230;</p>
<pre class="brush: bash;">
root: apachectl -t
Syntax OK
</pre>
<p>&#8230;and then restarting Apache</p>
<pre class="brush: bash;">
root: apachectl graceful
</pre>
<p>Upon which, all things being equal, PHP will pre-process all <i>.htm</i> and <i>.html</i> files. Obviously, there is an overhead in doing this but you&#8217;d have to be running a seriously hard-run site before this became an issue. Do remember, after all, that PHP has been highly optimised to integrate into HTML and I&#8217;m willing to bet you&#8217;ll not notice a difference in page load times (the time taken to download images will far outweigh any time spent by PHP doing it&#8217;s stuff)</p>
<p>Finally, note that AddType and AddHandler ARE different! As a very rough rule of thumb, I try and use AddType exclusively. FWIW, the difference is that AddHandler directives tell Apache how to handle file types and AddType directives tell Apache how to handle the contents of files. Any clearer? No, thought not. As I said, try and use AddType directives exclusively and you&#8217;re not likely to go far wrong.</p>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/addhandler' rel='tag' target='_self'>addhandler</a>, <a class='technorati-link' href='http://technorati.com/tag/addtype' rel='tag' target='_self'>addtype</a>, <a class='technorati-link' href='http://technorati.com/tag/apache' rel='tag' target='_self'>apache</a>, <a class='technorati-link' href='http://technorati.com/tag/httpd.conf' rel='tag' target='_self'>httpd.conf</a>, <a class='technorati-link' href='http://technorati.com/tag/mime' rel='tag' target='_self'>mime</a>, <a class='technorati-link' href='http://technorati.com/tag/php' rel='tag' target='_self'>php</a></p>

<!-- end wp-tags-to-technorati -->
<!--Amazon_CLS_IM_END-->]]></content:encoded>
			<wfw:commentRss>http://zeltus.eu/blog/?feed=rss2&amp;p=219</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>South West Motorcycle Show</title>
		<link>http://zeltus.eu/blog/?p=281</link>
		<comments>http://zeltus.eu/blog/?p=281#comments</comments>
		<pubDate>Mon, 30 Aug 2010 12:48:13 +0000</pubDate>
		<dc:creator>zeltus</dc:creator>
				<category><![CDATA[personal]]></category>
		<category><![CDATA[bike]]></category>
		<category><![CDATA[ixion]]></category>
		<category><![CDATA[south]]></category>
		<category><![CDATA[west]]></category>

		<guid isPermaLink="false">http://zeltus.eu/blog/?p=281</guid>
		<description><![CDATA[One reason that persuaded me into pushing myself too hard with a walk to Lyme Regis on Saturday was that meant I was in position to go to the South West Motorcycle Show the day after. I only heard about this after hearing about it on the invaluable but noisy Ixion motorcycle mailing list - Top tip guys!

I hadn't foreseen that I would be as stiff as a post after a marathon slog and that in particular my legs would seize up or otherwise refuse to work - just mounting my bike caused both thighs to start cramping and I sure as hell wasn't sure how I was going to dismount at the showground!

Still, I made it, I saw lotsa bikes, some gob-stoppingly awesome stunts and lots of desirable and expensive kit, none of which I really needed - I am pleased to say that I really do have all the kit I need to ride the beast in all weathers, not something I have had to worry about for several years but from now on, it is my only means of transport, come rain or snow. And knowing my luck, I'll be getting all of that! :-} 

I did take but a few pictures with my crap camera 'phone and here they are... 

