<?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>Mon, 05 Mar 2012 12:13:57 PST</lastBuildDate><generator>http://wordpress.org/?v=3.3.2</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>Adding a hook to the PHP output headers</title><link>http://feedproxy.google.com/~r/WayneMay/~3/oblt4-wbgQw/adding-a-hook-to-the-php-output-headers-03052012</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Mar 2012 12:13:57 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=375</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>With PHP 5.4 you can now easily add a callback function, using <strong>header_register_callback</strong>, to be called just before the headers are sent to the browser.</p>
<p>For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Type: text/plain'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'X-Test: test-header'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  header_register_callback<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'remove_XPoweredBy_header'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Testing'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This allows you to set a callback function, in this case, remove_XPoweredBy_header.</p>
<p>An example of something to do in this callback function:</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> remove_XPoweredBy_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    header_remove<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'X-Test'</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 will prevent &#8220;X-Test&#8221; from showing up in the headers.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/PKroOO7n0rmUHxXTzTOe08kzDpQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/PKroOO7n0rmUHxXTzTOe08kzDpQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PKroOO7n0rmUHxXTzTOe08kzDpQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/PKroOO7n0rmUHxXTzTOe08kzDpQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=oblt4-wbgQw:hQsq7lwva0c:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=oblt4-wbgQw:hQsq7lwva0c:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=oblt4-wbgQw:hQsq7lwva0c:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/oblt4-wbgQw" height="1" width="1"/>]]></content:encoded><description>With PHP 5.4 you can now easily add a callback function, using header_register_callback, to be called just before the headers are sent to the browser. For example: 1 2 3 4 5 6 header&amp;#40;'Content-Type: text/plain'&amp;#41;; header&amp;#40;'X-Test: test-header'&amp;#41;; &amp;#160; header_register_callback&amp;#40; 'remove_XPoweredBy_header' &amp;#41;; &amp;#160; echo 'Testing'; This allows you to set a callback function, in this case, remove_XPoweredBy_header. An example of something to do in this callback function: 1 2 3 4 function remove_XPoweredBy_header&amp;#40;&amp;#41; &amp;#123; header_remove&amp;#40;'X-Test'&amp;#41;; &amp;#125; This will prevent &amp;#8220;X-Test&amp;#8221; from showing up in the headers.</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/adding-a-hook-to-the-php-output-headers-03052012/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/adding-a-hook-to-the-php-output-headers-03052012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=adding-a-hook-to-the-php-output-headers</feedburner:origLink></item><item><title>Getting and Setting HTTP Response codes in PHP 5.4</title><link>http://feedproxy.google.com/~r/WayneMay/~3/1JEwbHupW1M/getting-and-setting-http-response-codes-in-php-5-4-03052012</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Mar 2012 11:56:56 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=371</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>A new function were added to PHP 5.4 that make getting and setting HTTP response code easy.</p>
<p>To get the current HTTP code, all you have to do is call the <strong>http_response_code</strong> function</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> http_response_code<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">//If all is ok, this should echo 200</span></pre></td></tr></table></div>

<p>To set the HTTP response code, add a parameter to the <strong>http_response_code</strong> function</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  http_response_code<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">404</span><span style="color: #009900;">&#41;</span>
  <span style="color: #b1b100;">echo</span> http_response_code<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">//This should echo 404 and return 404 in the header</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/PVgF9n1vNgCVBd5aKcRCOBUq34U/0/da"><img src="http://feedads.g.doubleclick.net/~a/PVgF9n1vNgCVBd5aKcRCOBUq34U/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PVgF9n1vNgCVBd5aKcRCOBUq34U/1/da"><img src="http://feedads.g.doubleclick.net/~a/PVgF9n1vNgCVBd5aKcRCOBUq34U/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=1JEwbHupW1M:3YohNqT-NSo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=1JEwbHupW1M:3YohNqT-NSo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=1JEwbHupW1M:3YohNqT-NSo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/1JEwbHupW1M" height="1" width="1"/>]]></content:encoded><description>A new function were added to PHP 5.4 that make getting and setting HTTP response code easy. To get the current HTTP code, all you have to do is call the http_response_code function 1 echo http_response_code&amp;#40;&amp;#41; //If all is ok, this should echo 200 To set the HTTP response code, add a parameter to the http_response_code function 1 2 http_response_code&amp;#40;404&amp;#41; echo http_response_code&amp;#40;&amp;#41; //This should echo 404 and return 404 in the header</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/getting-and-setting-http-response-codes-in-php-5-4-03052012/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/getting-and-setting-http-response-codes-in-php-5-4-03052012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-and-setting-http-response-codes-in-php-5-4</feedburner:origLink></item><item><title>Class Member Access on Instantiation with PHP 5.4</title><link>http://feedproxy.google.com/~r/WayneMay/~3/wtf_jpNQqeQ/class-member-access-on-instantiation-with-php-5-4-03052012</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Mar 2012 11:00:59 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=359</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>Class members can now be accessed on instantiation in PHP 5.4.  This is a very handy addition.<br />
Before PHP 5.4 you had to create an object into a variable, and then access the class member/function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">//The old way</span>
  <span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SomeClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">someFunction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>With PHP 5.4 you can access the class member directly on instantiation:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">//The new way</span>
  <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> SomeClass<span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">someFunction</span><span style="color: #009900;">&#40;</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/OpFLto7ppLGZlGlKVvwLF0TZiGA/0/da"><img src="http://feedads.g.doubleclick.net/~a/OpFLto7ppLGZlGlKVvwLF0TZiGA/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/OpFLto7ppLGZlGlKVvwLF0TZiGA/1/da"><img src="http://feedads.g.doubleclick.net/~a/OpFLto7ppLGZlGlKVvwLF0TZiGA/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=wtf_jpNQqeQ:dWiZIuEpRes:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=wtf_jpNQqeQ:dWiZIuEpRes:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=wtf_jpNQqeQ:dWiZIuEpRes:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/wtf_jpNQqeQ" height="1" width="1"/>]]></content:encoded><description>Class members can now be accessed on instantiation in PHP 5.4. This is a very handy addition. Before PHP 5.4 you had to create an object into a variable, and then access the class member/function: 1 2 3 //The old way $object = new SomeClass&amp;#40;&amp;#41;; $object-&amp;#62;someFunction&amp;#40;&amp;#41;; With PHP 5.4 you can access the class member directly on instantiation: 1 2 //The new way &amp;#40;new SomeClass&amp;#41;-&amp;#62;someFunction&amp;#40;&amp;#41;;</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/class-member-access-on-instantiation-with-php-5-4-03052012/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/class-member-access-on-instantiation-with-php-5-4-03052012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=class-member-access-on-instantiation-with-php-5-4</feedburner:origLink></item><item><title>Function Array Dereferencing in PHP 5.4</title><link>http://feedproxy.google.com/~r/WayneMay/~3/HzXDz3PMxJo/function-array-dereferencing-in-php-5-4-03052012</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Mar 2012 10:30:09 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=355</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>PHP now supports array dereferencing directly from a function call.  Before PHP 5.4 you had to store the returning value from a function into a variable, and then use the variable.<br />
Eg:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000088;">$cars</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ferrari,lamborghini,maserati,bugatti&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$cars</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//bugatti</span></pre></td></tr></table></div>

<p>Now with PHP 5.4 you can do it like this:</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> <span style="color: #000088;">$explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ferrari,lamborghini,maserati,bugatti&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//bugatti</span></pre></td></tr></table></div>

<p>Another example with your own function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">function</span> get_cars<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ferrari&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;lamborghini&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;maserati&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;bugatti&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">echo</span> get_cars<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//bugatti</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/butktZw-QNxcPbwxUelmF_JaKcM/0/da"><img src="http://feedads.g.doubleclick.net/~a/butktZw-QNxcPbwxUelmF_JaKcM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/butktZw-QNxcPbwxUelmF_JaKcM/1/da"><img src="http://feedads.g.doubleclick.net/~a/butktZw-QNxcPbwxUelmF_JaKcM/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=HzXDz3PMxJo:OwQ6VHiFxoQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=HzXDz3PMxJo:OwQ6VHiFxoQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=HzXDz3PMxJo:OwQ6VHiFxoQ:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/HzXDz3PMxJo" height="1" width="1"/>]]></content:encoded><description>PHP now supports array dereferencing directly from a function call. Before PHP 5.4 you had to store the returning value from a function into a variable, and then use the variable. Eg: 1 2 $cars = $explode&amp;#40;&amp;#34;,&amp;#34;, &amp;#34;ferrari,lamborghini,maserati,bugatti&amp;#34;&amp;#41;; echo $cars&amp;#91;3&amp;#93;; //bugatti Now with PHP 5.4 you can do it like this: 1 echo $explode&amp;#40;&amp;#34;,&amp;#34;, &amp;#34;ferrari,lamborghini,maserati,bugatti&amp;#34;&amp;#41;&amp;#91;3&amp;#93;; //bugatti Another example with your own function: 1 2 3 4 5 function get_cars&amp;#40;&amp;#41; &amp;#123; return &amp;#91;&amp;#34;ferrari&amp;#34;,&amp;#34;lamborghini&amp;#34;,&amp;#34;maserati&amp;#34;,&amp;#34;bugatti&amp;#34;&amp;#93;; &amp;#125; echo get_cars&amp;#40;&amp;#41;&amp;#91;3&amp;#93;; //bugatti</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/function-array-dereferencing-in-php-5-4-03052012/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/function-array-dereferencing-in-php-5-4-03052012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=function-array-dereferencing-in-php-5-4</feedburner:origLink></item><item><title>The Shorter Array Syntax in PHP 5.4</title><link>http://feedproxy.google.com/~r/WayneMay/~3/jDLJK-hN50I/the-shorter-array-syntax-in-php-5-4-03052012</link><category>PHP</category><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Wayne May</dc:creator><pubDate>Mon, 05 Mar 2012 10:00:28 PST</pubDate><guid isPermaLink="false">http://www.waynemay.com/?p=351</guid><content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<p>PHP 5.4 introduced a new shorter array syntax, similar to the syntax used in JavaScript.  </p>
<p>The old, longer syntax:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">//The old way</span>
  <span style="color: #000088;">$cars</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ferrari&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lamborghini&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;maserati&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;bugatti&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The new syntax is an alternative to the old syntax.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">  <span style="color: #666666; font-style: italic;">//The short way</span>
  <span style="color: #000088;">$cars</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;ferrari&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lamborghini&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;maserati&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;bugatti&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p><a href="http://feedads.g.doubleclick.net/~a/H1JAxpCAWPptErI--6vpPZ9JHDg/0/da"><img src="http://feedads.g.doubleclick.net/~a/H1JAxpCAWPptErI--6vpPZ9JHDg/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/H1JAxpCAWPptErI--6vpPZ9JHDg/1/da"><img src="http://feedads.g.doubleclick.net/~a/H1JAxpCAWPptErI--6vpPZ9JHDg/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=jDLJK-hN50I:FTKiz2G-X54:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:7Q72WNTAKBA"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=7Q72WNTAKBA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/WayneMay?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/WayneMay?a=jDLJK-hN50I:FTKiz2G-X54:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/WayneMay?i=jDLJK-hN50I:FTKiz2G-X54:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/WayneMay/~4/jDLJK-hN50I" height="1" width="1"/>]]></content:encoded><description>PHP 5.4 introduced a new shorter array syntax, similar to the syntax used in JavaScript. The old, longer syntax: 1 2 //The old way $cars = array&amp;#40;&amp;#34;ferrari&amp;#34;, &amp;#34;lamborghini&amp;#34;, &amp;#34;maserati&amp;#34;, &amp;#34;bugatti&amp;#34;&amp;#41;; The new syntax is an alternative to the old syntax. 1 2 //The short way $cars = &amp;#91;&amp;#34;ferrari&amp;#34;, &amp;#34;lamborghini&amp;#34;, &amp;#34;maserati&amp;#34;, &amp;#34;bugatti&amp;#34;&amp;#93;;</description><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.waynemay.com/the-shorter-array-syntax-in-php-5-4-03052012/feed</wfw:commentRss><slash:comments xmlns:slash="http://purl.org/rss/1.0/modules/slash/">0</slash:comments><feedburner:origLink>http://www.waynemay.com/the-shorter-array-syntax-in-php-5-4-03052012?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=the-shorter-array-syntax-in-php-5-4</feedburner:origLink></item><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; == 443&amp;#41; &amp;#123; $secure_connection = true; &amp;#125; &amp;#160; return $secure_connection; &amp;#125; I found this little nifty function on StackOverflow</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 easily be used in the following context: 6 7 8 9 10 $a = array&amp;#40;&amp;#34;dimension1&amp;#34; =&amp;#62; array&amp;#40;&amp;#34;dimension2&amp;#34; =&amp;#62; &amp;#34;I like it&amp;#34;&amp;#41; &amp;#41;; if&amp;#40; is_multi_array&amp;#40; $a &amp;#41; &amp;#41; &amp;#123; echo $a&amp;#91;'dimension1'&amp;#93;&amp;#91;'dimension2'&amp;#93;; &amp;#125;</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 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: &amp;#60;input type=&amp;#34;hidden&amp;#34; name=&amp;#34;group1&amp;#34; value=&amp;#34;&amp;#34; /&amp;#62; &amp;#60;input type=&amp;#34;radio&amp;#34; name=&amp;#34;group1.1&amp;#34; value=&amp;#34;1&amp;#34; tabindex=&amp;#34;10&amp;#34; /&amp;#62; Radio 1 &amp;#60;input... &lt;a href="http://www.waynemay.com/making-a-radio-group-tab-able-using-jquery-12082011"&gt;more&lt;/a&gt;</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 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 /** * Do a Safe Redirect * * This function will first try to do a... &lt;a href="http://www.waynemay.com/php-safe-redirect-function-12082011"&gt;more&lt;/a&gt;</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. I could do something like: 1 $fqdn = shell_exec&amp;#40;'hostname --fqdn'&amp;#41;; or using backticks, I can so something like: 1 $fqdn = `hostname --fqdn`; Notice that I am using backticks (`) and not single quotes (&amp;#8216;)</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></channel></rss>

