<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Winn.ws &#187; PHP</title>
	<atom:link href="http://winn.ws/archives/tag/php/feed" rel="self" type="application/rss+xml" />
	<link>http://winn.ws</link>
	<description>Standards-based design &#38; development</description>
	<lastBuildDate>Thu, 09 Sep 2010 14:05:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP/MySQL after 2010-005</title>
		<link>http://winn.ws/archives/492</link>
		<comments>http://winn.ws/archives/492#comments</comments>
		<pubDate>Sat, 28 Aug 2010 07:22:27 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Command Line]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=492</guid>
		<description><![CDATA[After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue:

In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)
Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock
Press Ctrl-O, then Enter to [...]]]></description>
			<content:encoded><![CDATA[<p>After applying Security Update 2010-05, some users have reported PHP and MySQL problems, including an inability to connect to MySQL databases. Apple reports that the following procedure resolves the database connection issue:</p>
<ol>
<li>In the Terminal type sudo nano /etc/php.ini (Terminal will ask you for your password)</li>
<li>Change: mysql.default_socket = to: mysql.default_socket = /tmp/mysql.sock</li>
<li>Press Ctrl-O, then Enter to save</li>
<li>Type sudo apachectl graceful</li>
</ol>
<p>Note that you may need to duplicate the original install php.ini.default file, just simply copy the contents of the file and create a php.ini. (cp php.ini.default php.ini)</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/492/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpArmory for WoW</title>
		<link>http://winn.ws/archives/484</link>
		<comments>http://winn.ws/archives/484#comments</comments>
		<pubDate>Mon, 23 Aug 2010 02:17:51 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[World of Warcraft]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=484</guid>
		<description><![CDATA[phpArmory is a PHP class library. It allows php software developers to easily access data from the World of Warcraft Armory website. This is useful because the Armory website contains up-to-date and official details on characters, guilds, and items in World of Warcraft.]]></description>
			<content:encoded><![CDATA[<p>phpArmory is a PHP class library. It allows php software developers to easily access data from the World of Warcraft Armory website. This is useful because the Armory website contains up-to-date and official details on characters, guilds, and items in World of Warcraft.</p>
<p> I discovered this simple library about 4 days ago and have been reviewing it. I came to a conclusion to use it after about 3 hours of playing with it! I was able to pull back all the information i needed to complete my new application and add-on to Wordboxes. Below i will cover a few samples of what this class will do.</p>
<h3>Character</h3>
<p> The first thing i did was try to pul my character information back. This was simple and done quickly with just a few minor calls. Once i got the multi level array back (when i say multi level I am talking about 4 to 5 levels deep) i was able to sift through it by using print_r() and a pre tag.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// First include the phpArmory class</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'classes/phpArmory.class.php'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpArmory<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Character lookup</span>
<span style="color: #000088;">$character</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">characterFetch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Realm'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$character</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p> Now, I wanted to take this a bit farther and list my characters gear with the image and item level. Below is a foreach loop, looping through the ‘item’ array. You may also notice i am 4 levels deep in the array at this point, i figured that out by just looking at the above code output. As i am looping through the ‘item’ array i will also have to step one level deeper into the ‘attributes’ array so i can see the information on the gear. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$character</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'characterinfo'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'charactertab'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'items'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'item'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;&lt;img class=&quot;gearicon&quot; src=&quot;http://www.wowarmory.com/wow-icons/_images/64x64/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'icon'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.jpg&quot; alt=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</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: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' (ilvl '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'level'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')&lt;/p&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h3>The above will output:</h3>
<p style="text-align:center;"><a class="colorbox" href="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/08/wowarmoryphp.jpg"><img src="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/08/wowarmoryphp-182x300.jpg" alt="" title="wowarmoryphp" width="182" height="300" class="aligncenter size-medium wp-image-485" /></a></p>
<h3>Items</h3>
<p>Another great thing about this library is that you are able to pull back just single items based on ID. This is great because after pulling back character info you also get gear ID&#8217;s. Then you can use the gear ID&#8217;s to get more information on that single item. This also makes it handy for tool tips as you will see on may wow sites.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Item lookup</span>
<span style="color: #000088;">$item</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">itemFetch</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">41922</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The above will be a large multi level array with that item information.</p>
<h3>Other stuff</h3>
<p>There are other things you can use this library for such as Guild lookups and PVP team lookups.</p>
<p>Download the <a href='http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/08/phpArmory.class.php_.zip'>phpArmory.class.php</a> and start building a web based wow app! Full documentation and support at <a href="http://phparmory.sourceforge.net/">http://phparmory.sourceforge.net/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/484/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP 5.3.3 Backwards incompatible change</title>
		<link>http://winn.ws/archives/470</link>
		<comments>http://winn.ws/archives/470#comments</comments>
		<pubDate>Wed, 04 Aug 2010 16:00:36 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=470</guid>
		<description><![CDATA[Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn&#8217;t affect non-namespaced classes.

namespace Foo;
class Bar &#123;
    public function Bar&#40;&#41; &#123;
        // treated as constructor in PHP 5.3.0-5.3.2
     [...]]]></description>
			<content:encoded><![CDATA[<p>Methods with the same name as the last element of a namespaced class name will no longer be treated as constructor. This change doesn&#8217;t affect non-namespaced classes.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">namespace</span> Foo<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> Bar <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// treated as constructor in PHP 5.3.0-5.3.2</span>
        <span style="color: #666666; font-style: italic;">// treated as regular method in PHP 5.3.3</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Update from <a href="http://php.net">PHP.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/470/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>var_export in PHP 5</title>
		<link>http://winn.ws/archives/468</link>
		<comments>http://winn.ws/archives/468#comments</comments>
		<pubDate>Wed, 04 Aug 2010 05:05:33 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=468</guid>
		<description><![CDATA[So var_export(mixed $expression [, bool $return = false ] ) outputs or returns a parsable string representation of a variable.]]></description>
			<content:encoded><![CDATA[<p>So var_export(mixed $expression [, bool $return = false ] ) outputs or returns a parsable string representation of a variable, it gets structured information about the given variable. It is similar to var_dump() with one exception: the returned representation is valid PHP code.</p>
<p>It&#8217;s quite simple to use, below is an example of how to use it.</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: #000000; font-weight: bold;">class</span> A <span style="color: #009900;">&#123;</span> 
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$a</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> A<span style="color: #339933;">;</span>
<span style="color: #000088;">$a</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">var</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
<span style="color: #990000;">var_export</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The output from the above code would be&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">A<span style="color: #339933;">::</span>__set_state<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
   <span style="color: #0000ff;">'var'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Note:</strong> var_export() does not handle circular references as it would be close to impossible to generate parsable PHP code for that. If you want to do something with the full representation of an array or object, use serialize(). </p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/468/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Data Filtering</title>
		<link>http://winn.ws/archives/459</link>
		<comments>http://winn.ws/archives/459#comments</comments>
		<pubDate>Mon, 19 Jul 2010 14:57:18 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=459</guid>
		<description><![CDATA[Time to leave $_GET and $_POST in the dust! In fact, you probably shouldn’t use $_GET and $_POST anymore. Since PHP 5.2, there is a new and better way to safely retrieve user-submitted data.]]></description>
			<content:encoded><![CDATA[<p>Time to leave $_GET and $_POST in the dust! In fact, you probably shouldn’t use $_GET and $_POST anymore. Since PHP 5.2, there is a new and better way to safely retrieve user-submitted data.</p>
<p>How many times have we heard about security issues in PHP applications stemming from unescaped GET and POST parameters? Proper escaping of input is a perennial problem with web development in general.</p>
<blockquote><p>On the database side, many worries over SQL injection have been squelched. The clever developers of PDO have constructed a library that analyzes data and escapes it appropriately. The problem of validating and sanitizing input is still a substantial issue on the front-end. Many PHP developers still spend time on development cycles building custom code to filter input or use a framework just for the validation helpers.</p></blockquote>
<p>PHP (5.2 onward) has a built-in filtering system that makes the tasks of validating and sanitizing data easy. Rather than accessing the $_GET and $_POST superglobals directly, you can make use of PHP functions like filter_input() and filter_input_array().</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$theGetVar</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> ‘someGetVar’<span style="color: #339933;">,</span> FILTER_SANITIZE_STRING<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Same as doing the below and running it through a validator</span>
<span style="color: #000088;">$theGetVar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'someGetVar'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Using post is also as easy, just change &#8220;INPUT_GET&#8221; to &#8220;INPUT_POST&#8221;</p>
<p>Are you sick of writing your own regex for validating an email address, url or even an IP?</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Email</span>
<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> ‘Email’<span style="color: #339933;">,</span> FILTER_VALIDATE_EMAIL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// URL</span>
<span style="color: #000088;">$url</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> ‘URL’<span style="color: #339933;">,</span> FILTER_VALIDATE_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// IP</span>
<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> ‘URL’<span style="color: #339933;">,</span> FILTER_VALIDATE_IP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You can use multiple filters on one input:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #990000;">filter_input</span><span style="color: #009900;">&#40;</span>INPUT_GET<span style="color: #339933;">,</span> ‘Email’<span style="color: #339933;">,</span> FILTER_VALIDATE_EMAIL<span style="color: #339933;">|</span> FILTER_SANITIZE_EMAIL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Filters won’t solve every security-related problem, but it&#8217;s a great step in the right direction when it comes to writing safe code. Below are the php.net docs:</p>
<ul>
<li><a href="http://www.php.net/manual/en/book.filter.php">Data Filtering</a></li>
<li><a href="http://us2.php.net/manual/en/function.filter-input.php">filter_input</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/459/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paulette Greene</title>
		<link>http://winn.ws/archives/454</link>
		<comments>http://winn.ws/archives/454#comments</comments>
		<pubDate>Sat, 17 Jul 2010 04:27:35 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Design & Layout]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Mail Chimp]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=454</guid>
		<description><![CDATA[One of the latest project i have done for <a href="http://scottcoleinteractive.com/">SCI</a> is for a client named Paulette Greene. They are a large realtor shop here in the DFW (Dallas/Fort Worth) area.]]></description>
			<content:encoded><![CDATA[<p>One of the latest project i have done for <a href="http://scottcoleinteractive.com/">SCI</a> is for a client named Paulette Greene. They are a large realtor shop here in the DFW (Dallas/Fort Worth) area. The site was not built on any CMS per customer request but did have an integration with Mail Chimp for a newsletter.</p>
<p style="text-align:center;"><a class="colorbox" href="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/07/pg_large.jpg"><img src="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/07/pg_small.jpg" alt="" title="pg_small" width="560" height="100" class="alignnone size-full wp-image-456" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/454/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Query Strings in Codeigniter</title>
		<link>http://winn.ws/archives/448</link>
		<comments>http://winn.ws/archives/448#comments</comments>
		<pubDate>Thu, 01 Jul 2010 01:11:46 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=448</guid>
		<description><![CDATA[In some cases you might prefer to use query strings URLs and not the pretty URLs. CodeIgniter optionally supports this capability which can be enabled in your application/config.php file.]]></description>
			<content:encoded><![CDATA[<p>In some cases you might prefer to use query strings URLs and not the pretty URLs. CodeIgniter optionally supports this capability, which can be enabled in your application/config.php file. </p>
<p><strong>&#8220;Ugly&#8221; URLs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">index<span style="color: #339933;">.</span>php?c<span style="color: #339933;">=</span>users<span style="color: #339933;">&amp;</span>m<span style="color: #339933;">=</span>home<span style="color: #339933;">&amp;</span>id<span style="color: #339933;">=</span><span style="color: #cc66cc;">305</span></pre></div></div>

<p>If you open your config file you&#8217;ll see these items:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'enable_query_strings'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'controller_trigger'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'c'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'function_trigger'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'m'</span><span style="color: #339933;">;</span></pre></div></div>

<p>If you change &#8220;enable_query_strings&#8221; to TRUE this feature will become active. Your controllers and functions will then be accessible using the &#8220;trigger&#8221; words you&#8217;ve set to invoke your controllers and methods:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">index<span style="color: #339933;">.</span>php?c<span style="color: #339933;">=</span>controller<span style="color: #339933;">&amp;</span>m<span style="color: #339933;">=</span>method</pre></div></div>

<blockquote><p>Please note: If you are using query strings you will have to build your own URLs, rather than utilizing the URL helpers (and other helpers that generate URLs, like some of the form helpers) as these are designed to work with segment based URLs.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/448/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP5 Method Chaining</title>
		<link>http://winn.ws/archives/437</link>
		<comments>http://winn.ws/archives/437#comments</comments>
		<pubDate>Wed, 23 Jun 2010 17:34:25 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=437</guid>
		<description><![CDATA[One improvement over PHP4 to PHP5 is something called method chaining and enables us to do pretty cool things like...]]></description>
			<content:encoded><![CDATA[<p>One improvement over PHP4 to PHP5 is something called method chaining and enables us to do pretty cool things like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP 5</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">breed</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Min Pin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Black'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a class="colorbox" href="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/06/skooter_large.jpg" style="float:left; margin:8px;" title="Skooter Winn"><img src="http://dhbbuddo7esu2.cloudfront.net/wp-content/uploads/2010/06/skooter_75.jpg" alt="Skooter Winn" class="portimg" /></a><small>This post was powered by Skooter ($dog->breed(&#8216;Min Pin&#8217;)->color(&#8216;Black&#8217;);)</small></p>
<p>So really what&#8217;s this all about? Well, one change (of many) between PHP4 and PHP5 is that now methods can return objects. That&#8217;s only a small change but allows for a new way of thinking about how you handle objects and their methods.</p>
<p>To be able to chain methods together, you need to be able to return an object. The returned object does not necessarily need be the same one from which the method is being called. Let&#8217;s put all of this into action.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Dog <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$dog_color</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$dog_breed</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> breed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_breed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> color<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_color</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> seedog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Breed: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_breed</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; Color: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_color</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now, we can create a new Dog and give them a breed and color. Using the seedog method.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP 4 (OLD STYLE)</span>
<span style="color: #000088;">$dog</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Dog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">breed</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Min Pin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Black'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">seedog</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Will echo = Breed: Min Pin Color: Black</span></pre></div></div>

<p><strong>Implementing Method Chaining</strong></p>
<p>We will be using the same class from above but adding two lines to it like so:</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Dog <span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$dog_color</span><span style="color: #339933;">;</span>
     <span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$dog_breed</span><span style="color: #339933;">;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> breed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_breed</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// &lt;- Returning the object</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> color<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_color</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$val</span><span style="color: #339933;">;</span>
          <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// &lt;- Returning the object</span>
     <span style="color: #009900;">&#125;</span>
&nbsp;
     <span style="color: #000000; font-weight: bold;">function</span> seedog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Breed: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_breed</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; Color: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dog_color</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Using the class above we can now use method chaining!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// PHP 5</span>
<span style="color: #000088;">$dog</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Dog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dog</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">breed</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Min Pin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">color</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Black'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">seedog</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Will echo = Breed: Min Pin Color: Black</span></pre></div></div>

<p>It will give you the same result but your code is much cleaner and easier to read.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/437/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nice Dog Framework</title>
		<link>http://winn.ws/archives/435</link>
		<comments>http://winn.ws/archives/435#comments</comments>
		<pubDate>Tue, 22 Jun 2010 13:56:57 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Platforms]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=435</guid>
		<description><![CDATA[I just came across this mico php framework a few nights ago. When i say "micro" i mean micro, this framework is one file!]]></description>
			<content:encoded><![CDATA[<p>I just came across this mico php framework a few nights ago. When i say &#8220;micro&#8221; i mean micro, this framework is one file! Below is a sample using controllers and routes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require</span> <span style="color: #0000ff;">'NiceDog.php'</span><span style="color: #339933;">;</span>
R<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">controller</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MyController'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">action</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">on</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'GET'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">class</span> MyController <span style="color: #000000; font-weight: bold;">extends</span> C <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'views/index.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>You can now access the above by using http://local/mycontroller/</strong></p>
<p>You may also add layouts to the mix by using:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">layout</span><span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;MyLayout.php&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To allow the routes to work, you will need to add the following to your vhosts or .htaccess file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>IfModule mod_rewrite<span style="color: #339933;">.</span>c<span style="color: #339933;">&gt;</span>
    RewriteEngine On
    RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!-</span>d
    RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_FILENAME<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!-</span>f
    RewriteRule ^<span style="color: #009900;">&#40;</span><span style="color: #339933;">.*</span><span style="color: #009900;">&#41;</span>$ index<span style="color: #339933;">.</span>php?url<span style="color: #339933;">=</span>$<span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#91;</span>QSA<span style="color: #339933;">,</span>L<span style="color: #009900;">&#93;</span>
<span style="color: #339933;">&lt;/</span>IfModule<span style="color: #339933;">&gt;</span></pre></div></div>

<p>So if your looking for a mico php framework you may want to checkout <a href="http://github.com/bastos/nicedog">Nice Dog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/435/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3.0 “Thelonious”</title>
		<link>http://winn.ws/archives/432</link>
		<comments>http://winn.ws/archives/432#comments</comments>
		<pubDate>Thu, 17 Jun 2010 19:32:12 +0000</pubDate>
		<dc:creator>Greg Winn</dc:creator>
				<category><![CDATA[Design & Layout]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://winn.ws/?p=432</guid>
		<description><![CDATA[The new Wordpress 3.0 is out and full of new stuff to play with! It's a great improvement for us as developers and as the end user.]]></description>
			<content:encoded><![CDATA[<p>The new Wordpress 3.0 is out and full of new stuff to play with! It&#8217;s a great improvement for us as developers and as the end user. Theme developers have new APIs that allow them to easily implement custom backgrounds, headers, shortlinks, menus (no more file editing), post types, and taxonomies.</p>
<blockquote><p>Arm your vuvuzelas: WordPress 3.0, the thirteenth major release of WordPress and the culmination of half a year of work by 218 contributors, is now available for download (or upgrade within your dashboard). Major new features in this release include a sexy new default theme called Twenty Ten&#8230;</p></blockquote>
<p><embed src="http://v.wordpress.com/wp-content/plugins/video/flvplayer.swf?ver=1.21" type="application/x-shockwave-flash" width="640" height="360" wmode="transparent" seamlesstabbing="true" allowfullscreen="true" allowscriptaccess="always" overstretch="true" flashvars="guid=BQtfIEY1&amp;width=640&amp;height=360&amp;locksize=no&amp;dynamicseek=false&amp;qc_publisherId=p-18-mFEk4J448M" title="Introducing WordPress 3.0 &quot;Thelonious&quot;"></embed></p>
<p>This is great news for me as I use Wordpress for many projects and have been waiting on this for some time now. I have downloaded a copy and have already played with it.</p>
<p><a href="http://wrdbx.es/2736my">Visit the Wordpress site for more information</a><br />
<a href="http://wordpress.org/development/2010/06/thelonious/">Download the new Wordpress 3.0!</a></p>
<p>If you&#8217;re a new developer looking to get into Wordpress development i recommend <a href="http://www.amazon.com/gp/product/0470560541?ie=UTF8&#038;tag=winnws-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0470560541">Professional WordPress (Wrox Programmer to Programmer)</a><img src="http://www.assoc-amazon.com/e/ir?t=winnws-20&#038;l=as2&#038;o=1&#038;a=0470560541" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
 for getting started.</p>
]]></content:encoded>
			<wfw:commentRss>http://winn.ws/archives/432/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 5/11 queries in 0.004 seconds using memcached
Content Delivery Network via Amazon Web Services: CloudFront: dhbbuddo7esu2.cloudfront.net

Served from: winn.ws @ 2010-09-09 22:37:52 -->