<?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>PHail [dot net] Blog - Design, Programming, and other things. &#187; php</title>
	<atom:link href="http://phail.net/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://phail.net</link>
	<description>A creative and sometimes technical blog about Design and Programming as well as other things.</description>
	<lastBuildDate>Thu, 10 Feb 2011 02:12:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>PHP Class Practice: Creating a Simple Pet Script</title>
		<link>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/</link>
		<comments>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 18:12:13 +0000</pubDate>
		<dc:creator>Mike Wojo</dc:creator>
				<category><![CDATA[Codes & Scripts]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[pet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://phail.net/?p=14</guid>
		<description><![CDATA[For the vast majority of the time I&#8217;ve been programming I haven&#8217;t used Classes in my code. They are relatively new to me. Because of this, I decided to practice writing classes since I realized how useful they are. Here&#8217;s something I made when I was learning. What We&#8217;re Making Today: We&#8217;re going to be [...]]]></description>
			<content:encoded><![CDATA[<p>For the vast majority of the time I&#8217;ve been programming I haven&#8217;t used Classes in my code. They are relatively new to me. Because of this, I decided to practice writing classes since I realized how useful they are. Here&#8217;s something I made when I was learning.</p>
<p><strong>What We&#8217;re Making Today:</strong><br />
We&#8217;re going to be making a small script comprised of a class, called <strong>Pet</strong>, with variables and functions inside of it to perform actions. Also keep in mind that this is <em>extremely</em> simple and most likely cannot be used for anything outside of practice without heavy modification.</p>
<p><strong>Let&#8217;s Begin, Shall We?</strong></p>
<ol>
<li>Create a new file. Let&#8217;s call it <strong>pet.php</strong>.</li>
<li>Open up the file and prepare for editing! (I use Dreamweaver for most code editing, but you can use plenty of other programs like the built in TextEdit (Mac) and NotePad (Windows).</li>
<li>Always remember to save it as a PHP file! Saving it accidentally as .txt or .rtf will make it not work at all.</li>
</ol>
<p><strong>Now for some code.</strong></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//Some class practice.</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Pet<br />
<span style="color: #009900;">&#123;</span></div></div>
<p>We&#8217;ve now started the file and recognized it&#8217;s a PHP document. Then we initiated the class &#8220;Pet&#8221;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$age</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$fullness</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$health</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">70</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$dead</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></div></div>
<p>We&#8217;ve now created the variables name, age, fullness, and health for the class to use, and a public variable &#8216;dead&#8217;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> SetName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$txt</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$txt</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;You have named your pet &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$txt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fullness: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Health: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Age: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Now we have a <strong>public function</strong> (A function that can be used outside of just inside the class code) called SetName. By calling the function with a string parameter, you assign that string to the class variable $name. It also echoes some text telling you about the pet.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> GetName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Since the variables we set earlier in the class (like $name) are <b>not public</b>, we can only access them through the inside code.  So, using this simple function called GetName(), we can retrieve the contents of the $name variable for that object.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Feed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//Increase pet's fullness by a random amount between 5 and 10.</span><br />
<span style="color: #000088;">$fulladd</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$fulladd</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&lt;p&gt;You have fed &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; some food. Fullness increased by <span style="color: #006699; font-weight: bold;">$fulladd</span>.&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Every pet needs to be fed, right?  Well, since I said this is simple, we are just picking a number between 5 and 10 to add to it&#8217;s Fullness total.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> PassTime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #666666; font-style: italic;">//Simulate some sort of reality I suppose..</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">*</span><span style="color:#800080;">.10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">-=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//Make sure stats are whole numbers</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/ceil"><span style="color: #990000;">ceil</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #666666; font-style: italic;">//Increase age by a day? (Not really logical, but oh well.)</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p style='color:#999999;'&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Some time has passed.&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Fullness: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Health: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Age: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">age</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/p&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Alrighty, this is a fun one.  We&#8217;re pretty much giving a little illustion that there&#8217;s time with our little pet.  We&#8217;re decreasing it&#8217;s fullness by 10% plus 5 (so it <i>can</i> die eventually), decreasing it&#8217;s hunger by a random percentage between 10% and 25% plus 2 (same reason as fullness), and using the php function <b>ceil</b> to round the numbers up so they are whole numbers.  We&#8217;re then increasing age by one count (a day perhaps?), making the text color gray, and echo&#8217;ing out what happened to the screen.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Killed<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fullness</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">health</span> <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p style='color:red;'&gt;Your pet, &lt;b&gt;&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/b&gt;, is now in pet heaven.&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dead</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>This function checks to see if the pet has died due to hunger and health failure.  Once it&#8217;s fullness or health reach 0 or lower, the pet &#8220;goes to a better place&#8221;. <img src='http://phail.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Notice that it&#8217;s variable $dead is set true.  This will be used for exiting the loop later on.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#125;</span></div></div>
<p>Close up our class and we&#8217;re ready for the main part: The Loop!</p>
<p>We&#8217;re going to be using a loop to simulate a created pet&#8217;s life.  This loop will keep going as long as the pet is alive, and stop when it dies.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">//Demonstrate the Pet class!</span><br />
<span style="color: #000088;">$Fluffy</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Pet<span style="color: #339933;">;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SetName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Fluffy The Sheep&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>We&#8217;ve created our pet and set his name to &#8220;Fluffy The Sheep&#8221;.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dead</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><a href="http://www.php.net/rand"><span style="color: #990000;">rand</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Feed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">PassTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000088;">$Fluffy</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Killed</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;">//Is our poor pet deceased?</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The final part is the loop.  Like I said before, the loop keeps going as long as the pet is alive.  Once it is dead (determined by the Killed() function), it&#8217;s state changes and the loop exits.</p>
<p>And there you have it! Try running the program and see your little pet in action. Feel free to also customize the experience (name it!).  I hope you were able to learn something new out of this. <img src='http://phail.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   Happy coding!</p>
<p>(By the way, using these settings my pet lived to be around 12-14 age.)</p>
]]></content:encoded>
			<wfw:commentRss>http://phail.net/2008/04/21/php-class-practice-creating-a-simple-pet-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My Little 1337 (leet) Speak Generator</title>
		<link>http://phail.net/2008/04/15/my-little-1337-leet-speak-generator/</link>
		<comments>http://phail.net/2008/04/15/my-little-1337-leet-speak-generator/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 18:24:06 +0000</pubDate>
		<dc:creator>Mike Wojo</dc:creator>
				<category><![CDATA[Codes & Scripts]]></category>
		<category><![CDATA[1337]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[leet]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://phail.net/?p=9</guid>
		<description><![CDATA[For fun in class the other day, I wrote a little &#8220;1337&#8243; speak generator.  It&#8217;s written in PHP, and it consists of just one small script page.  (It has also come to my attention that there are various degrees of 1337, so I would consider my translation to be somewhat advanced.  1337 translation help from [...]]]></description>
			<content:encoded><![CDATA[<p>For fun in class the other day, I wrote a little &#8220;1337&#8243; speak generator.  It&#8217;s written in PHP, and it consists of just one small script page.  (It has also come to my attention that there are various degrees of 1337, so I would consider my translation to be somewhat advanced.  1337 translation help from Wikipedia.)</p>
<p>Try it <a title="1337!!!11" href="http://phail.net/i-s/1337.php" target="_blank">here</a>.</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">/* Leet (1337) Speak generator! */</span><br />
<span style="color: #666666; font-style: italic;">/* Takes ordinary words and turns them to computer geek gibberish. */</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Lets be able to use all those Post variables easily.</span><br />
<a href="http://www.php.net/extract"><span style="color: #990000;">extract</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//Convert the text?</span><br />
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to_convert</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$old</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$to_convert</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Keep old text</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$find</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'b'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'c'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'d'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'e'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'f'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'g'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'h'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'i'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'j'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'k'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'l'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'n'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'o'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'p'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'q'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'r'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'s'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'t'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'u'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'w'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'x'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'y'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'z'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$repl</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'8'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&amp;copy;&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'[)'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'3'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'|='</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'6'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'#'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'_|'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'|&lt; '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'|v|'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'N'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'|*'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Q'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'R'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'5'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'7'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'(_)'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'V'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'VV'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'&gt;&lt; '</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Y'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$to_convert</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$find</span><span style="color: #339933;">,</span><span style="color: #000088;">$repl</span><span style="color: #339933;">,</span><a href="http://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to_convert</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;p&gt;&lt;b&gt;&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/nl2br"><span style="color: #990000;">nl2br</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$to_convert</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;/b&gt;&lt;br /&gt;(&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/nl2br"><span style="color: #990000;">nl2br</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/stripslashes"><span style="color: #990000;">stripslashes</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$old</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #666666; font-style: italic;">//No text to convert, must be the Main Page.</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;form action='<span style="color: #006699; font-weight: bold;">$PHP_SELF</span>' method='post'&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Text to be converted:&lt;br /&gt;&lt;textarea id='to_convert' name='to_convert' rows='20' cols='35'&gt;&lt;/textarea&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&lt;input type='submit' value='1337 speak!'/&gt;&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/form&gt;&quot;</span><span style="color: #339933;">;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://phail.net/2008/04/15/my-little-1337-leet-speak-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

