<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Wayne May</title><link>http://www.waynemay.com</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/WayneMay" /><description>Website Developer, Android Evangelist, and Hardware Hacker.</description><language>en</language><lastBuildDate>Thu, 12 Jan 2012 12:31:30 PST</lastBuildDate><generator>http://wordpress.org/?v=3.3.1</generator><sy:updatePeriod xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">hourly</sy:updatePeriod><sy:updateFrequency xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">1</sy:updateFrequency><xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/WayneMay" /><feedburner:info uri="waynemay" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>33.921765</geo:lat><geo:long>-117.48812</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-nd/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-nd/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><item><title>Check if PHP is using HTTPS (SSL)</title><link>http://feedproxy.google.com/~r/WayneMay/~3/9iEWumdlg_w/check-if-php-is-using-https-ssl-12092011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Fri, 09 Dec 2011 13:00:03 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=249</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I had to come up with a way to check if PHP is running in SSL mode today. This will work on both Apache, Nginx and IIS</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> is_ssl<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$secure_connection</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTPS'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!==</span> <span style="color: #0000ff;">'off'</span>
        <span style="color: #339933;">||</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_PORT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">443</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$secure_connection</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$secure_connection</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I found this little nifty function on <a href="http://stackoverflow.com/questions/1175096/how-to-find-out-if-you-are-using-https-without-serverhttps">StackOverflow</a</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Cg0-YzhWGvfSRzsxfW2TlzmAm-s/0/da"><img src="http://feedads.g.doubleclick.net/~a/Cg0-YzhWGvfSRzsxfW2TlzmAm-s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Cg0-YzhWGvfSRzsxfW2TlzmAm-s/1/da"><img src="http://feedads.g.doubleclick.net/~a/Cg0-YzhWGvfSRzsxfW2TlzmAm-s/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=9iEWumdlg_w:8tw6O8jqNTw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=9iEWumdlg_w:8tw6O8jqNTw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=9iEWumdlg_w:8tw6O8jqNTw:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/9iEWumdlg_w" height="1" width="1"/>]]></content:encoded><description>I had to come up with a way to check if PHP is running in SSL mode today. This will work on both Apache, Nginx and IIS 1 2 3 4 5 6 7 8 9 10 11 12 function is_ssl&amp;#40;&amp;#41; &amp;#123; $secure_connection = false; &amp;#160; if &amp;#40;!empty&amp;#40;$_SERVER&amp;#91;'HTTPS'&amp;#93;&amp;#41; &amp;#38;&amp;#38; $_SERVER&amp;#91;'HTTPS'&amp;#93; !== 'off' &amp;#124;&amp;#124; $_SERVER&amp;#91;'SERVER_PORT'&amp;#93; == [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/check-if-php-is-using-https-ssl-12092011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/check-if-php-is-using-https-ssl-12092011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=check-if-php-is-using-https-ssl</feedburner:origLink></item><item><title>Detecting a Multi-Dimensional Array in PHP</title><link>http://feedproxy.google.com/~r/WayneMay/~3/NcpKzpg2owI/detecting-a-multi-dimensional-array-in-php-12092011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Fri, 09 Dec 2011 08:00:21 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=224</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I recently had to find a quick way to check if an array is a multi-dimensional array, only to find that there are no PHP built-in function to do this. Here is a quick and easy way to do it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> is_multi_array<span style="color: #009900;">&#40;</span> <span style="color: #990000;">array</span> <span style="color: #000088;">$arr</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">key</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This can easily be used in the following context:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dimension1&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dimension2&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;I like it&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> is_multi_array<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$a</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$a</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dimension1'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'dimension2'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/_KgZeCINzNLkAllrojd2FpEuvdE/0/da"><img src="http://feedads.g.doubleclick.net/~a/_KgZeCINzNLkAllrojd2FpEuvdE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_KgZeCINzNLkAllrojd2FpEuvdE/1/da"><img src="http://feedads.g.doubleclick.net/~a/_KgZeCINzNLkAllrojd2FpEuvdE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=NcpKzpg2owI:D_8a89Mtt7k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=NcpKzpg2owI:D_8a89Mtt7k:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=NcpKzpg2owI:D_8a89Mtt7k:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/NcpKzpg2owI" height="1" width="1"/>]]></content:encoded><description>I recently had to find a quick way to check if an array is a multi-dimensional array, only to find that there are no PHP built-in function to do this. Here is a quick and easy way to do it: 1 2 3 4 function is_multi_array&amp;#40; array $arr &amp;#41; &amp;#123; return is_array&amp;#40;$arr&amp;#91;key&amp;#40;$arr&amp;#41;&amp;#93;&amp;#41;; &amp;#125; This can [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/detecting-a-multi-dimensional-array-in-php-12092011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/detecting-a-multi-dimensional-array-in-php-12092011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=detecting-a-multi-dimensional-array-in-php</feedburner:origLink></item><item><title>Making a Radio Group Tab-able Using jQuery</title><link>http://feedproxy.google.com/~r/WayneMay/~3/ht8M2HiOqHg/making-a-radio-group-tab-able-using-jquery-12082011</link><category>HTML &amp; CSS</category><category>JavaScript</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Thu, 08 Dec 2011 13:00:08 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=243</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Recently I had to come up with a solution to make radio boxes tab-able. Mozilla Firefox allows you to tab over each radio box in a group, however, all other browsers do not. The solution is actually quite simple. First, in your HTML make sure to name your radio boxes with the same name, but also add a .1, .2, .3, and so on, to separate them. You will also need a hidden element. This is the one you want to do validation against. For example:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;group1&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;group1.1&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> Radio 1
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;group1.2&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;11&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> Radio 2
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;radio&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;group1.3&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;12&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span> Radio 3</pre></div></div>

<p>Now add a little bit of code that will parse once the DOM is ready:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
        $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            rt <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RadioTabs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            rt.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;group1&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;group1.1&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;group1.2&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;group1.3&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>All this does is tell the RadioTabs class (coming next) which tabs will be in the group. Finally, add this somewhere on you page. Preferably on a separate page.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">	<span style="color: #009966; font-style: italic;">/* Create Tabable Radio Boxes */</span>
	<span style="color: #003366; font-weight: bold;">function</span> RadioTabs<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #009966; font-style: italic;">/* Declare Private Members and Methods */</span>
		<span style="color: #003366; font-weight: bold;">var</span> hidden <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> group <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> events <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* void Bind Events to each individual Radio Box */</span>
		<span style="color: #003366; font-weight: bold;">var</span> bindEvents <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//Loop through Events</span>
			<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> e <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> e <span style="color: #339933;">&lt;</span> events.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> e<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//Loop through Radio Buttons</span>
				<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> g <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> g <span style="color: #339933;">&lt;</span> group.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> g<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">//Add a Rel value to each group box - to be used in the bind</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input:radio[name=&quot;'</span> <span style="color: #339933;">+</span> group<span style="color: #009900;">&#91;</span>g<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #339933;">,</span> g<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #006600; font-style: italic;">//Bind actual events to each radio box</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input:radio[name=&quot;'</span> <span style="color: #339933;">+</span> group<span style="color: #009900;">&#91;</span>g<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span>events<span style="color: #009900;">&#91;</span>e<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> event <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #003366; font-weight: bold;">var</span> n <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name=&quot;'</span> <span style="color: #339933;">+</span> hidden <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> group<span style="color: #009900;">&#91;</span>n<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">//Step through radio group and set to false</span>
						<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> group.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> group<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> group<span style="color: #009900;">&#91;</span>n<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input:radio[name=&quot;'</span> <span style="color: #339933;">+</span> group<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;]:checked'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009966; font-style: italic;">/* Declare Public Members and Methods */</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #009966; font-style: italic;">/* string Set the Hidden Input Element */</span>
			setHidden    <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span> value <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				hidden <span style="color: #339933;">=</span> value<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			<span style="color: #009966; font-style: italic;">/* array Set the Radio Group Elements */</span>
			setGroup    <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span> values <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				group <span style="color: #339933;">=</span> values<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			<span style="color: #009966; font-style: italic;">/* array Set the Events to bind to */</span>
			setEvents    <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span> values <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				events <span style="color: #339933;">=</span> values<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			<span style="color: #009966; font-style: italic;">/* void Init the script */</span>
			init            <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span> hid<span style="color: #339933;">,</span> grp<span style="color: #339933;">,</span> evt <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setHidden</span><span style="color: #009900;">&#40;</span> hid <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setGroup</span><span style="color: #009900;">&#40;</span> grp <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">setEvents</span><span style="color: #009900;">&#40;</span> evt <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				bindEvents<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>All the above piece of code does is it will allow you to tab through the radio boxes, and then set the hidden elements value to that of the selected radio box. You might have to tweak a little bit with CSS in IE7 and 8 (I don’t support 6 anymore) to make it show that the box is selected. This should do the trick</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">    input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span>radio<span style="color: #00AA00;">&#93;</span><span style="color: #3333ff;">:focus </span><span style="color: #00AA00;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#000</span> <span style="color: #993333;">dotted</span> <span style="color: #993333;">thin</span><span style="color: #00AA00;">;</span>
    <span style="color: #00AA00;">&#125;</span></pre></div></div>


<p><a href="http://feedads.g.doubleclick.net/~a/zAYTqkIwksdhloawRtYApsNZcDs/0/da"><img src="http://feedads.g.doubleclick.net/~a/zAYTqkIwksdhloawRtYApsNZcDs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/zAYTqkIwksdhloawRtYApsNZcDs/1/da"><img src="http://feedads.g.doubleclick.net/~a/zAYTqkIwksdhloawRtYApsNZcDs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=ht8M2HiOqHg:znq0ezy4a_I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=ht8M2HiOqHg:znq0ezy4a_I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=ht8M2HiOqHg:znq0ezy4a_I:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/ht8M2HiOqHg" height="1" width="1"/>]]></content:encoded><description>Recently I had to come up with a solution to make radio boxes tab-able. Mozilla Firefox allows you to tab over each radio box in a group, however, all other browsers do not. The solution is actually quite simple. First, in your HTML make sure to name your radio boxes with the same name, but [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/making-a-radio-group-tab-able-using-jquery-12082011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/making-a-radio-group-tab-able-using-jquery-12082011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=making-a-radio-group-tab-able-using-jquery</feedburner:origLink></item><item><title>PHP Safe Redirect Function</title><link>http://feedproxy.google.com/~r/WayneMay/~3/tT6SGIVR800/php-safe-redirect-function-12082011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Thu, 08 Dec 2011 08:00:02 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=227</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>I see PHP code every day making use of the header function. Its the standard way to make redirects in PHP, but will fail if ANY output was sent to the browser before its called. There is a safer way to do this, which use JavaScript and meta redirects as a fail safe:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #009933; font-style: italic;">/**
     * Do a Safe Redirect
     *
     * This function will first try to do a server-side redirect, if it is not possible, if will fall back to a
     * Javascript redirect, if that fails, it will try a HTML redirect.
     * @param $url
     */</span>
    <span style="color: #000000; font-weight: bold;">function</span> safe_redirect<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$method</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'PHP'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        try
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">headers_sent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//If headers are not sent yet... then do a php redirect</span>
                <span style="color: #339933;">@</span><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Location: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        catch<span style="color: #009900;">&#40;</span> Exception <span style="color: #000088;">$ex</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//If headers are sent... do a JavaScript redirect...</span>
            <span style="color: #666666; font-style: italic;">//if javascript disabled, do html redirect.</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;script type=&quot;text/javascript&quot;&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'window.location.href=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;;'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/script&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;noscript&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;meta http-equiv=&quot;refresh&quot; content=&quot;0;url='</span><span style="color: #339933;">.</span><span style="color: #000088;">$url</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/noscript&gt;'</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">exit</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Basically, this will check to see if headers were sent, if not, it will allow for a PHP header redirect, If output were set, it will make use of JavaScript, and, as a backup if JavaScript is not installed, it will cause a meta redirect.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/gyfDu3ckjQeEoayujeK8NZR085k/0/da"><img src="http://feedads.g.doubleclick.net/~a/gyfDu3ckjQeEoayujeK8NZR085k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/gyfDu3ckjQeEoayujeK8NZR085k/1/da"><img src="http://feedads.g.doubleclick.net/~a/gyfDu3ckjQeEoayujeK8NZR085k/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=tT6SGIVR800:VVtoYdIEbwY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tT6SGIVR800:VVtoYdIEbwY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=tT6SGIVR800:VVtoYdIEbwY:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/tT6SGIVR800" height="1" width="1"/>]]></content:encoded><description>I see PHP code every day making use of the header function. Its the standard way to make redirects in PHP, but will fail if ANY output was sent to the browser before its called. There is a safer way to do this, which use JavaScript and meta redirects as a fail safe: 1 2 [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/php-safe-redirect-function-12082011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/php-safe-redirect-function-12082011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-safe-redirect-function</feedburner:origLink></item><item><title>PHP use Backticks as Execution Operators</title><link>http://feedproxy.google.com/~r/WayneMay/~3/IfjMpFviNzA/php-use-backticks-as-execution-operators-12072011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Wed, 07 Dec 2011 13:00:50 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=218</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>PHP use backticks as execution operators, which will return the output of to be assigned to a variable. Any code between backticks will be executed as a shell command &#8211; the backtick operator is identical to shell_exec()</p>
<p>One example where I found this useful was to get the fully qualified domain name of a server. I could do something like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fqdn</span> <span style="color: #339933;">=</span> <span style="color: #990000;">shell_exec</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hostname --fqdn'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>or using backticks, I can so something like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$fqdn</span> <span style="color: #339933;">=</span> `hostname <span style="color: #339933;">--</span>fqdn`<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Notice that I am using backticks (`) and not single quotes (&#8216;)</p>

<p><a href="http://feedads.g.doubleclick.net/~a/ccG-uzJ6DJplzsITThRVR0Ly9YQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/ccG-uzJ6DJplzsITThRVR0Ly9YQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ccG-uzJ6DJplzsITThRVR0Ly9YQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/ccG-uzJ6DJplzsITThRVR0Ly9YQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=IfjMpFviNzA:Y7B5iz7063c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=IfjMpFviNzA:Y7B5iz7063c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=IfjMpFviNzA:Y7B5iz7063c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/IfjMpFviNzA" height="1" width="1"/>]]></content:encoded><description>PHP use backticks as execution operators, which will return the output of to be assigned to a variable. Any code between backticks will be executed as a shell command &amp;#8211; the backtick operator is identical to shell_exec() One example where I found this useful was to get the fully qualified domain name of a server. [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/php-use-backticks-as-execution-operators-12072011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/php-use-backticks-as-execution-operators-12072011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=php-use-backticks-as-execution-operators</feedburner:origLink></item><item><title>Testing if a string is serialized in PHP</title><link>http://feedproxy.google.com/~r/WayneMay/~3/LzSqO7EfTZI/testing-if-a-string-is-serialized-in-php-12072011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Wed, 07 Dec 2011 08:00:38 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=229</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>PHP offers a way to store arrays and objects through serialization. The problem is, there is no actual PHP function the check if data is serialized. I came up with a dirty little function to help with that:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">function</span> is_serial<span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">@</span><span style="color: #990000;">unserialize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>unserialize will return FALSE if you pass a value that is not serialized, BUT, it will also throw an E_NOTICE error at the same time. To get around that, I add the suppressor (@) and then I attempt to unserialize the data. </p>

<p><a href="http://feedads.g.doubleclick.net/~a/00__bT-9ts7KP1aKVcw1E75o1GE/0/da"><img src="http://feedads.g.doubleclick.net/~a/00__bT-9ts7KP1aKVcw1E75o1GE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/00__bT-9ts7KP1aKVcw1E75o1GE/1/da"><img src="http://feedads.g.doubleclick.net/~a/00__bT-9ts7KP1aKVcw1E75o1GE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=LzSqO7EfTZI:Ooju1LH_EvM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=LzSqO7EfTZI:Ooju1LH_EvM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=LzSqO7EfTZI:Ooju1LH_EvM:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/LzSqO7EfTZI" height="1" width="1"/>]]></content:encoded><description>PHP offers a way to store arrays and objects through serialization. The problem is, there is no actual PHP function the check if data is serialized. I came up with a dirty little function to help with that: 1 2 3 4 function is_serial&amp;#40;$data&amp;#41; &amp;#123; return &amp;#40;@unserialize&amp;#40;$data&amp;#41; !== false&amp;#41;; &amp;#125; unserialize will return FALSE if [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/testing-if-a-string-is-serialized-in-php-12072011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/testing-if-a-string-is-serialized-in-php-12072011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=testing-if-a-string-is-serialized-in-php</feedburner:origLink></item><item><title>Create a custom feed in WordPress</title><link>http://feedproxy.google.com/~r/WayneMay/~3/DA7ZdhM7uM0/create-a-custom-feed-in-wordpress-12062011</link><category>WordPress</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Tue, 06 Dec 2011 13:00:06 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=221</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Recently I was faced with the task to create various formats of the WordPress feed. My initial thought was to create a new “page” and use that as the feed. So you would call something like domain.com/custom-feed/ Then I found the add_feed() function: I could not find proper documentation for the function in the Codex, but here is an attempt to explain how it works. This make is easier to call domain.com/feed=custom-rss to get the custom RSS feed.</p>
<p><strong>About add_feed</strong><br />
This function takes two parameters: Feed Name, and Callback Function. The callback function will handle the feed template, and will have access to Loop.</p>
<p>Timing matters The add_feed function MUST be called after WordPress is completely initialized. In my tests. I found it to work in the <em>init</em> action hook.</p>
<p><strong>The code</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> custom_rss_feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     add_feed<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'custom-rss'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_rss_feed_template'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'custom_rss_feed'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> custom_rss_feed_template<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     load_template<span style="color: #009900;">&#40;</span> TEMPLATEPATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'custom_rss_feed.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>The code explained</strong><br />
First, we add an action to call the custom rss function during the <em>init</em>. Then, we define the new custom rss feed using add_feed. This feed will then give use a &#8216;custom-rss&#8217; feed. The custom_rss_feed_template is called when feed=custom-rss is specified. The custom_rss_feed_template function calls your template file.</p>
<p><strong>Creating the template</strong><br />
At this point, all you still need to do is to create the custom template. The easiest way to go about this is to copy the wordpress/wp-includes/feed-rss2.php template to your theme directory. rename it to custom_rss_feed.php and start modifying the file to your needs. All of the WordPress functions will still work, because you are still in the Loop.</p>
<p><strong>Afterthought</strong><br />
You can then take it a step further and create rewrite rules so that you don&#8217;t need the query string feed=custom-rss but instead something like feed/custom-rss/</p>

<p><a href="http://feedads.g.doubleclick.net/~a/PJ16_4UTAxRZLzVQoHVXJi8YFHA/0/da"><img src="http://feedads.g.doubleclick.net/~a/PJ16_4UTAxRZLzVQoHVXJi8YFHA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PJ16_4UTAxRZLzVQoHVXJi8YFHA/1/da"><img src="http://feedads.g.doubleclick.net/~a/PJ16_4UTAxRZLzVQoHVXJi8YFHA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=DA7ZdhM7uM0:9AWkePIBR5o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=DA7ZdhM7uM0:9AWkePIBR5o:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=DA7ZdhM7uM0:9AWkePIBR5o:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/DA7ZdhM7uM0" height="1" width="1"/>]]></content:encoded><description>Recently I was faced with the task to create various formats of the WordPress feed. My initial thought was to create a new “page” and use that as the feed. So you would call something like domain.com/custom-feed/ Then I found the add_feed() function: I could not find proper documentation for the function in the Codex, [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/create-a-custom-feed-in-wordpress-12062011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/create-a-custom-feed-in-wordpress-12062011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=create-a-custom-feed-in-wordpress</feedburner:origLink></item><item><title>Unlimited number of function parameters in PHP</title><link>http://feedproxy.google.com/~r/WayneMay/~3/YlvMGqJL1kU/unlimited-number-of-function-parameters-in-php-12062011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Tue, 06 Dec 2011 08:00:20 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=233</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Every so often I find myself needing to pass an unknown amount of arguments into a function. For example, assume you want to create a function to add a bunch of variables: add( $a, $b, $c, $d, … ) This can easily be done using the PHP function func_get_args().</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">function</span> add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>  
        <span style="color: #000088;">$total</span>  <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">func_get_args</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>  
            <span style="color: #000088;">$total</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>  
        <span style="color: #009900;">&#125;</span>  
        <span style="color: #b1b100;">return</span> <span style="color: #000088;">$total</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You can then call the function with as many arguments as you want.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">echo</span> add<span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/iisySGcO3UKuL5j4yXE6aEv_v1E/0/da"><img src="http://feedads.g.doubleclick.net/~a/iisySGcO3UKuL5j4yXE6aEv_v1E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/iisySGcO3UKuL5j4yXE6aEv_v1E/1/da"><img src="http://feedads.g.doubleclick.net/~a/iisySGcO3UKuL5j4yXE6aEv_v1E/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=YlvMGqJL1kU:lasGSgKPXRg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=YlvMGqJL1kU:lasGSgKPXRg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=YlvMGqJL1kU:lasGSgKPXRg:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/YlvMGqJL1kU" height="1" width="1"/>]]></content:encoded><description>Every so often I find myself needing to pass an unknown amount of arguments into a function. For example, assume you want to create a function to add a bunch of variables: add( $a, $b, $c, $d, … ) This can easily be done using the PHP function func_get_args(). 1 2 3 4 5 6 [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/unlimited-number-of-function-parameters-in-php-12062011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/unlimited-number-of-function-parameters-in-php-12062011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=unlimited-number-of-function-parameters-in-php</feedburner:origLink></item><item><title>Converting from a RHEL install to a CentOS install</title><link>http://feedproxy.google.com/~r/WayneMay/~3/tvzRY5N2U10/converting-from-a-rhel-install-to-a-centos-install-12052011</link><category>Web Servers</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Dec 2011 13:00:16 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=247</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>A couple of days ago I received a RHEL (Red Hat Enterprise Linux) Virtual Machine image from our IT support team. The problem was that the image was made using an evaluation copy of Red Hat. I figured I would convert it to CentOS, since there is no registration required. Here is what I did, and maybe it will help you if you need to upgrade a server with an expired subscription. From the root of your filesystem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#yum clean all</span>
<span style="color: #666666; font-style: italic;">#mkdir /usr/src/centos</span>
<span style="color: #666666; font-style: italic;">#cd /usr/src/centos</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-5-5.el5.centos.i386.rpm</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/5/os/i386/CentOS/centos-release-notes-5.5-0.i386.rpm</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-updatesd-0.9-2.el5.noarch.rpm</span>
<span style="color: #666666; font-style: italic;">#wget http://mirror.centos.org/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm</span>
<span style="color: #666666; font-style: italic;">#rpm --import RPM-GPG-KEY-CentOS-5</span>
<span style="color: #666666; font-style: italic;">#/bin/rpm -e --nodeps redhat-release</span>
<span style="color: #666666; font-style: italic;">#/bin/rpm -e --nodeps rhn-client-tools</span>
<span style="color: #666666; font-style: italic;">#/bin/rpm -e --nodeps yum-rhn-plugin</span>
<span style="color: #666666; font-style: italic;">#rpm -Uvh --force *.rpm</span>
<span style="color: #666666; font-style: italic;">#yum upgrade</span>
<span style="color: #666666; font-style: italic;">#reboot</span></pre></div></div>

<p>That should do the trick! </p>

<p><a href="http://feedads.g.doubleclick.net/~a/9d2koASUCc9vZjmZAXo9HCcj350/0/da"><img src="http://feedads.g.doubleclick.net/~a/9d2koASUCc9vZjmZAXo9HCcj350/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9d2koASUCc9vZjmZAXo9HCcj350/1/da"><img src="http://feedads.g.doubleclick.net/~a/9d2koASUCc9vZjmZAXo9HCcj350/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=tvzRY5N2U10:T7cs2QcLQP0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=tvzRY5N2U10:T7cs2QcLQP0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=tvzRY5N2U10:T7cs2QcLQP0:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/tvzRY5N2U10" height="1" width="1"/>]]></content:encoded><description>A couple of days ago I received a RHEL (Red Hat Enterprise Linux) Virtual Machine image from our IT support team. The problem was that the image was made using an evaluation copy of Red Hat. I figured I would convert it to CentOS, since there is no registration required. Here is what I did, [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/converting-from-a-rhel-install-to-a-centos-install-12052011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">2</slash:comments><feedburner:origLink>http://www.waynemay.com/converting-from-a-rhel-install-to-a-centos-install-12052011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=converting-from-a-rhel-install-to-a-centos-install</feedburner:origLink></item><item><title>Interfaces vs. Abstract classes in PHP</title><link>http://feedproxy.google.com/~r/WayneMay/~3/KMZMXBV1fis/interfaces-vs-abstract-classes-in-php-12052011</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Dec 2011 11:30:47 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=278</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Many developers do not know the main difference between <strong>intefaces</strong> <a class="simple-footnote" title="http://php.net/manual/en/language.oop5.interfaces.php" id="return-note-278-1" href="#note-278-1"><sup>1</sup></a> and <strong>abstract classes</strong> <a class="simple-footnote" title="http://www.php.net/manual/en/language.oop5.abstract.php" id="return-note-278-2" href="#note-278-2"><sup>2</sup></a>, since they seem to provide almost the same capabilities.<br />
Hopefully this will help you decide which to use in your application.</p>
<p><strong>When to use Interfaces?</strong><br />
Interfaces allow you to specify which methods a class must provide, without having to know how they are handled.<br />
Methods specified in an interface MUST be implemented in a class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">interface</span> SomeInterface
<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$variable</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><strong>When to use Abstract classes?</strong><br />
An abstract class provides structure.  It usually defines default implementations.<br />
Methods specified in an abstract class can be ignored in a subclass.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> SomeInterface
<span style="color: #009900;">&#123;</span>
  abstract <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> doSomething<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$variable</span> <span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">//Put some code here if you like</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This table attempts to define the difference between Interfaces and Abstract classes.</p>
<style type="text/css">
.comparison { border-collapse: collapse; margin-bottom: 10px; }
.comparison th { background-color: #F0F0F0; }
.comparison td, .comparison th { padding: 4px; border: 1px solid #F0F0F0; }
</style>
<table class="comparison">
<thead>
<tr>
<th>Feature</th>
<th>Interface</th>
<th>Abstract class</th>
</tr>
</thead>
<tbody>
<tr>
<td>multiple inheritance:</td>
<td>a class can implement several interfaces.</td>
<td>A class can only extend one abstract class.</td>
</tr>
<tr>
<td>default implementation:</td>
<td>An interface can not provide any code at all.</td>
<td>An abstract class can provide default code, and parts that can be overridden.</td>
</tr>
<tr>
<td>constants:</td>
<td>Interface constants work exactly like class constants, however, they can not be overridden.</td>
<td>Abstract classes can have their constants overridden by extending classes.</td>
</tr>
<tr>
<td>convenience:</td>
<td>Interfaces can easily be added to a third party class.</td>
<td>Third party classes might have to be rewritten to extend the abstract class.</td>
</tr>
<tr>
<td>is-a vs -able or can-do:</td>
<td>Interfaces describe the abilities of a class, and not the identity of the class (It defines what the class can do).</td>
<td>An abstract class defines the code identity of the descendants. (It defines what the class is).  For example: If you defined a Dog as abstract, then Shepherds are descendants of Dogs.</td>
</tr>
<tr>
<td>visibility:</td>
<td>All declared methods MUST be public.</td>
<td>Methods can be public or protected.  If the abstract class defines a method as protected, then it can be declared as protected or public in the sub-class.</td>
</tr>
<tr>
<td>homogeneity:</td>
<td>If various implementations share the same method signatures, the an interface should be used. If subclasses are going to different (heterogeneous), then use interfaces.</td>
<td>If various implementations share a common &#8220;kind&#8221; or behavior, the an abstract class should be used.  For example, if sub-classes are going to be similar (homogeneous), use abstract classes.</td>
</tr>
<tr>
<td>performance:</td>
<td>Interfaces are almost double as slow as abstract classes.</td>
<td>Pretty fast.</td>
</tr>
<tr>
<td>terseness:</td>
<td>Interfaces are typically not designed to share.</td>
<td>Shared code can be put in abstract classes.</td>
</tr>
<tr>
<td>maintenance:</td>
<td>If you add a new method to an interface, then you MUST update all implementations of the interface and add code to implement the new method.</td>
<td>If a new method is added to a class, you can provide default implementation for it.  All existing code will continue to work without change.</td>
</tr>
</tbody>
</table>
<p>Updated: Dec-05-2011: Added visibility to the table.</p>
<div class="simple-footnotes"><p class="notes">Notes:</p><ol><li id="note-278-1">http://php.net/manual/en/language.oop5.interfaces.php <a href="#return-note-278-1">&#8617;</a></li><li id="note-278-2">http://www.php.net/manual/en/language.oop5.abstract.php <a href="#return-note-278-2">&#8617;</a></li></ol></div>
<p><a href="http://feedads.g.doubleclick.net/~a/-GodVxrLcpA17b4ormoIY9G7yzQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/-GodVxrLcpA17b4ormoIY9G7yzQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-GodVxrLcpA17b4ormoIY9G7yzQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/-GodVxrLcpA17b4ormoIY9G7yzQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=KMZMXBV1fis:I_AWpYAHyck:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=KMZMXBV1fis:I_AWpYAHyck:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=KMZMXBV1fis:I_AWpYAHyck:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/KMZMXBV1fis" height="1" width="1"/>]]></content:encoded><description>Many developers do not know the main difference between intefaces and abstract classes, since they seem to provide almost the same capabilities. Hopefully this will help you decide which to use in your application. When to use Interfaces? Interfaces allow you to specify which methods a class must provide, without having to know how they [...]</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/interfaces-vs-abstract-classes-in-php-12052011/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">1</slash:comments><feedburner:origLink>http://www.waynemay.com/interfaces-vs-abstract-classes-in-php-12052011?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=interfaces-vs-abstract-classes-in-php</feedburner:origLink></item></channel></rss>

