<?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>WildPHP</title>
	<atom:link href="http://www.wildphp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wildphp.com</link>
	<description>Free Video Tutorials, Scripts, and Articles for You!</description>
	<lastBuildDate>Sun, 08 Jan 2012 00:18:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Removing the .php Extension From a URL</title>
		<link>http://www.wildphp.com/articles/removing-the-php-extension-from-a-url/</link>
		<comments>http://www.wildphp.com/articles/removing-the-php-extension-from-a-url/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 00:18:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Articles]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=397</guid>
		<description><![CDATA[If you are developing a website in PHP then most of your files will end in the .PHP file extension. This works just fine for your development, but when you release your website the .php extension is just added characters in the URL. Most websites that use PHP simple have the extension of the page [...]]]></description>
			<content:encoded><![CDATA[<p>If you are developing a website in PHP then most of your files will end in the .PHP file extension. This works just fine for your development, but when you release your website the .php extension is just added characters in the URL.</p>
<p>Most websites that use PHP simple have the extension of the page removed. This leads to cleaner, shorter, and easier to read URLs. It is also better for your SEO or Search Engine Optimization.</p>
<p>Using a simple .htaccess file with a few lines we can automatically add the .php file extension to any URL without it. This means something like example.com/page will look like example.com/page.php to the computer, but still retain the cleaner look of example.com/page to the user. Note: You can still explicitly call any page even with this change.</p>
<h1>Step #1</h1>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-402" style="border: 1px solid #d5d5d5;" title="ht-tutorial2" src="http://www.wildphp.com/wp-content/uploads/2012/01/ht-tutorial21.png" alt="" width="630" height="100" /></p>
<div>Create a file called .htaccess and place it in the root or home directory of your website.</div>
<div></div>
<h1>Step #2</h1>
<div></div>
<div>Add the following lines of code to your .htaccess file this will add a .php file extension to all the pages without a file extension.</div>
<pre class="brush: php">
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</pre>
<div></div>
<h1>Step #3</h1>
<p>To keep your users from getting lost you should add a 404 redirect as well. If a user enters a wrong URL the web server will try to display that wrong page with a .php extension. To fix this, a 404 redirect will redirect all non-existent URLs to a predetermined 404 page. Note you will have to have some sort of 404 page for this to work. Don&#8217;t forget to change http://example.org/404 to the URL of your own 404 page.<br />
&nbsp;</p>
<pre class="brush: php">
ErrorDocument 404 http://example.org/404

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/articles/removing-the-php-extension-from-a-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple PHP IRC Logger</title>
		<link>http://www.wildphp.com/scripts/simple-php-irc-logger/</link>
		<comments>http://www.wildphp.com/scripts/simple-php-irc-logger/#comments</comments>
		<pubDate>Tue, 11 May 2010 01:14:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=307</guid>
		<description><![CDATA[Description Simple PHP IRC Logger is a simple PHP IRC Bot class designed to connect to an IRC server, and generate HTML log files. It is based on a modified version of  Simple PHP IRC Bot. This script is designed and intended to be built upon for your needs, so if you have any problems [...]]]></description>
			<content:encoded><![CDATA[<h1>Description</h1>
<p>Simple PHP IRC Logger is a simple PHP IRC Bot class designed to connect to an IRC server, and generate HTML log files. It is based on a modified version of  <a href="http://www.wildphp.com/scripts/simple-php-irc-bot/">Simple PHP IRC Bot</a>. This script is designed and intended to be built upon for your needs, so if you have any problems please ask in our <a href="http://forum.wildphp.com">forum</a>. Please also follow some of the notes below for guidance. For future updates and scripts, don’t forget to <a href="http://feeds.feedburner.com/wildphp">subscribe</a>.</p>
<h1>Features and Functions</h1>
<ul>
<li>!join #channel – Joins the specified IRC channel</li>
<li>!part #channel – Leaves the specified IRC channel</li>
<li>!say #channel Message – Says message in the specified IRC channel</li>
<li>!restart – Quits and restarts the script. (Helpful while testing the  script)</li>
<li>!shutdown – Quits and stops the script.</li>
</ul>
<p>Usage and output:</p>
<blockquote><p>&lt;random-user&gt; !say #nystic_chat hello there<br />
&lt;wildphp-bot&gt; hello there</p></blockquote>
<ul>
<li>Enable/Disable Logging (PHP Script Variable)</li>
<li>Enable/Disable Logging Warning Message (PHP Script Variable)</li>
</ul>
<p>Note the script in the current version of the script, all joined channels will be added to the single log file for the day.</p>
<h1>Installation</h1>
<ol>
<li>Download or copy paste the script from this page</li>
<li>(Optional) If downloaded rename the file to bot.php ( Sorry, the  blog will only allow me to upload it as log-bot.txt)</li>
<li>Edit the $config array in the script to the server settings, should  be self explanatory</li>
<li>Download and install <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a></li>
<li>Place bot.php in the htdocs folder of your XAMPP installation</li>
<li>Don’t forget to start the Apache server by pressing the start button  in the XAMPP Control Panel</li>
<li>Go to <a href="http://localhost/bot.php">http://localhost/log-bot.php</a>,  and the bot should connect and join the channel you specified in about  30 seconds</li>
<li>If you have warning enabled the bot should say &#8220;Chat Logging has been [Enabled]&#8221; when entering the default room</li>
<li>If you have logging enabled an HTML file should appear in the same directory, it will be updated when anyone says something in the room</li>
</ol>
<h1>Code</h1>
<p>Download <a href="http://www.wildphp.com/wp-content/uploads/2010/05/log-bot.txt" target="_blank">log-bot.txt</a> (Right click, Save As…)</p>
<p>or</p>
<pre class="brush: php">

&lt;?php

/**
* Simple PHP IRC Logger
*
* PHP Version 5
*
* LICENSE: This source file is subject to Creative Commons Attribution
* 3.0 License that is available through the world-wide-web at the following URI:
* http://creativecommons.org/licenses/by/3.0/.  Basically you are free to adapt
* and use this script commercially/non-commercially. My only requirement is that
* you keep this header as an attribution to my work. Enjoy!
*
* @category   Chat Room Scipt
* @package    Simple PHP IRC Logger
* @author     Super3boy &lt;admin@wildphp.com&gt;
* @copyright  2010, The Nystic Network
* @license    http://creativecommons.org/licenses/by/3.0/
* @link       http://wildphp.com (Visit for updated versions and more free scripts!)
* @version    1.0.0 (Last updated 04-04-2010)
*
*/

//So the bot doesn&#039;t stop.
set_time_limit(0);
ini_set(&#039;display_errors&#039;, &#039;on&#039;);

/* --- Varibles and Config Info --- */

//Sample connection data.
$config = array(
//General Config Info
&#039;server&#039; =&gt; &#039;chat.freenode.net&#039;,
&#039;port&#039;   =&gt; 6667,
&#039;name&#039;   =&gt; &#039;wildphp-bot&#039;,
&#039;nick&#039;   =&gt; &#039;wildphp-bot&#039;,
&#039;pass&#039;   =&gt; &#039;&#039;,

//Logging Config Info
&#039;channel&#039; =&gt; &#039;#nystic_chat&#039;,
&#039;logging&#039; =&gt; true,
&#039;warning&#039; =&gt; true,
);

/*
//Set your connection data.
$config = array(
//General Config Info
&#039;server&#039; =&gt; &#039;irc.example.com&#039;,
&#039;port&#039;   =&gt; 6667,
&#039;name&#039;   =&gt; &#039;real name&#039;,
&#039;nick&#039;   =&gt; &#039;user&#039;,
&#039;pass&#039;   =&gt; &#039;pass&#039;,

//Logging Config Info
&#039;channel&#039; =&gt; &#039;#channel&#039;,
&#039;logging&#039; =&gt; true,
&#039;warning&#039; =&gt; true,
);
*/

/* --- IRCBot Class --- */

class IRCBot {

//This is going to hold our TCP/IP connection
var $socket;

//This is going to hold all of the messages both server and client
var $ex = array();
//var $logging = true;

/*
Construct item, opens the server connection, logs the bot in
@param array
*/

function __construct($config)
{
$this-&gt;socket = fsockopen($config[&#039;server&#039;], $config[&#039;port&#039;]);
$this-&gt;login($config);
$this-&gt;main($config);
}

/*
Logs the bot in on the server
@param array
*/

function login($config)
{
$this-&gt;send_data(&#039;USER&#039;, $config[&#039;nick&#039;].&#039; wildphp.com &#039;.$config[&#039;nick&#039;].&#039; :&#039;.$config[&#039;name&#039;]);
$this-&gt;send_data(&#039;NICK&#039;, $config[&#039;nick&#039;]);
$this-&gt;join_channel($config[&#039;channel&#039;]);

if($config[&#039;logging&#039;]) {
$date = date(&quot;n-j-y&quot;);
$time = date(&#039;h:i:s A&#039;);
$logfile = fopen(&quot;$date-log.html&quot;,&quot;a&quot;);
fwrite($logfile,&quot;&lt;br/&gt;**************** Logging Started at $time ****************&lt;br/&gt;&quot;);
fclose($logfile);

//Warn that logging has been enabled
if($config[&#039;warning&#039;]) {
$this-&gt;send_data(&#039;PRIVMSG &#039;.$config[&#039;channel&#039;].&#039; :&#039;, &quot;Chat Logging has been [Enabled]&quot;);
}
}
}

/*
This is the workhorse function, grabs the data from the server and displays on the browser
*/

function main($config)
{
$data = fgets($this-&gt;socket, 256);

echo nl2br($data);

flush();

$this-&gt;ex = explode(&#039; &#039;, $data);

if($this-&gt;ex[0] == &#039;PING&#039;)
{
$this-&gt;send_data(&#039;PONG&#039;, $this-&gt;ex[0]); //Plays ping-pong with the server to stay connected.
}

//Logs the chat
if($config[&#039;logging&#039;])
{
$logtxt = $this-&gt;filter_log($this-&gt;ex[1], $this-&gt;ex[2], $this-&gt;ex[0], $this-&gt;get_msg($this-&gt;ex)); //Gets human readable text from irc data
if($logtxt != null) { //Writes to log if it is a message
$date = date(&quot;n-j-y&quot;);
$logfile = fopen(&quot;$date-log.html&quot;,&quot;a&quot;);
fwrite($logfile,&quot;$logtxt&lt;br /&gt;&quot;);
fclose($logfile);
}
}

$command = str_replace(array(chr(10), chr(13)), &#039;&#039;, $this-&gt;ex[3]);

switch($command) //List of commands the bot responds to from a user.
{
case &#039;:!join&#039;:
$this-&gt;join_channel($this-&gt;ex[4]);
break;

case &#039;:!quit&#039;:
$this-&gt;send_data(&#039;QUIT&#039;, &#039;Wildphp.com Made Bot&#039;);
break;

case &#039;:!op&#039;:
$this-&gt;op_user();
break;

case &#039;:!deop&#039;:
$this-&gt;op_user(&#039;&#039;,&#039;&#039;, false);
break;

case &#039;:!protect&#039;:
$this-&gt;protect_user();
break;

case &#039;:!say&#039;:
$message = &quot;&quot;;
for($i=4; $i &lt;= (count($this-&gt;ex)); $i++)
{
$message .= $this-&gt;ex[$i].&quot; &quot;;
}

$this-&gt;send_data(&#039;PRIVMSG &#039;.$config[&#039;channel&#039;].&#039; :&#039;, $message);
break;

case &#039;:!restart&#039;:
//Warn that logging has been disabled
if($config[&#039;warning&#039;]) {
$this-&gt;send_data(&#039;PRIVMSG &#039;.$config[&#039;channel&#039;].&#039; :&#039;, &quot;Chat Logging has been [Disabled]&quot;);
}

echo &quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;3\&quot;&gt;&quot;;
if($config[&#039;logging&#039;]) {
$date = date(&quot;n-j-y&quot;);
$time = date(&#039;h:i:s A&#039;);
$logfile = fopen(&quot;$date-log.html&quot;,&quot;a&quot;);
fwrite($logfile,&quot;&lt;br/&gt;**************** Logging Ended at $time ****************&lt;br/&gt;&quot;);
fclose($logfile);
}
exit;
case &#039;:!shutdown&#039;:
//Warn that logging has been disabled
if($config[&#039;warning&#039;]) {
$this-&gt;send_data(&#039;PRIVMSG &#039;.$config[&#039;channel&#039;].&#039; :&#039;, &quot;Chat Logging has been [Disabled]&quot;);
}

if($config[&#039;logging&#039;]) {
$date = date(&quot;n-j-y&quot;);
$time = date(&#039;h:i:s A&#039;);
$logfile = fopen(&quot;$date-log.html&quot;,&quot;a&quot;);
fwrite($logfile,&quot;&lt;br/&gt;**************** Logging Ended at $time ****************&lt;br/&gt;&quot;);
fclose($logfile);
}
exit;
}

$this-&gt;main($config);
}

/* --- IRCBot Class&#039;s Functions --- */

function filter_log($type, $chan, $nick, $msg)
{
$nick = ltrim($nick, &quot;:&quot;);
$nick = substr($nick, 0, strpos($nick, &quot;!&quot;));

$msg = ltrim($msg, &quot;:&quot;);

if($type == &quot;PRIVMSG&quot;)
{
return date(&quot;[H:i]&quot;).&quot; &amp;amp;amp;amp;lt;&quot;.$nick.&quot;&amp;amp;amp;amp;gt; &quot;.$msg;
}
return null    ;
}

function get_msg($arr)
{
$message = &quot;&quot;;
for($i=3; $i &lt;= (count($this-&gt;ex)); $i++)
{
$message .= $this-&gt;ex[$i].&quot; &quot;;
}
return $message;
}

function send_data($cmd, $msg = null) //displays stuff to the broswer and sends data to the server.
{
if($msg == null)
{
fputs($this-&gt;socket, $cmd.&quot;\r\n&quot;);
echo &#039;&lt;strong&gt;&#039;.$cmd.&#039;&lt;/strong&gt;&lt;br /&gt;&#039;;
} else {

fputs($this-&gt;socket, $cmd.&#039; &#039;.$msg.&quot;\r\n&quot;);
echo &#039;&lt;strong&gt;&#039;.$cmd.&#039; &#039;.$msg.&#039;&lt;/strong&gt;&lt;br /&gt;&#039;;
}

}

function join_channel($channel) //Joins a channel, used in the join function.
{
if(is_array($channel))
{
foreach($channel as $chan)
{
$this-&gt;send_data(&#039;JOIN&#039;, $chan);
}

} else {
$this-&gt;send_data(&#039;JOIN&#039;, $channel);
}
}

function protect_user($user = &#039;&#039;)
{
if($user == &#039;&#039;)
{
if(php_version() &gt;= &#039;5.3.0&#039;)
{
$user = strstr($this-&gt;ex[0], &#039;!&#039;, true);
} else {
$length = strstr($this-&gt;ex[0], &#039;!&#039;);
$user   = substr($this-&gt;ex[0], 0, $length);
}
}

$this-&gt;send_data(&#039;MODE&#039;, $this-&gt;ex[2] . &#039; +a &#039; . $user);
}

function op_user($channel = &#039;&#039;, $user = &#039;&#039;, $op = true) {
if($channel == &#039;&#039; || $user == &#039;&#039;)
{
if($channel == &#039;&#039;)
{
$channel = $this-&gt;ex[2];
}

if($user == &#039;&#039;)
{

if(php_version() &gt;= &#039;5.3.0&#039;)
{
$user = strstr($this-&gt;ex[0], &#039;!&#039;, true);
} else {
$length = strstr($this-&gt;ex[0], &#039;!&#039;);
$user   = substr($this-&gt;ex[0], 0, $length);
}
}
}

if($op)
{
$this-&gt;send_data(&#039;MODE&#039;, $channel . &#039; +o &#039; . $user);
} else {
$this-&gt;send_data(&#039;MODE&#039;, $channel . &#039; -o &#039; . $user);
}
}
}

//Start the bot
$bot = new IRCBot($config);
?&gt;
</pre>
<h1>Warning</h1>
<p>This script uses PHP sockets, and most shared hosting and some  servers have it disabled by default. This script runs continuously so it  is not recommended to run on shared hosting accounts. We recommend you  run it locally using the instructions below.</p>
<h1>Help/Support</h1>
<p>If you are having any problems with the PHP bot, need help extending it, or just have an idea, feel free to make a post on <a href="http://wildphp.com/forum">our forum</a>.</p>
<h1>Conclusion</h1>
<p>Thanks for trying out our Simple PHP IRC Logger. You can check out the base class <a href="http://www.wildphp.com/scripts/simple-php-irc-bot/">here</a>. If their are any bugs in the  code <a href="../contact/">please let us know</a> right away. Also thanks to <a href="http://acidavengers.co.uk/">KillerAuzzie</a> for the for <a href="http://acidavengers.co.uk/code/php/creating-a-php-based-irc-bot/">tutorial</a>/basecode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/scripts/simple-php-irc-logger/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple PHP IRC Bot</title>
		<link>http://www.wildphp.com/scripts/simple-php-irc-bot/</link>
		<comments>http://www.wildphp.com/scripts/simple-php-irc-bot/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:40:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=219</guid>
		<description><![CDATA[Description Simple PHP IRC Bot, is a simple PHP IRC Bot class designed to connect to an IRC server, run a few simple commands.  This script is designed and intended to be built upon, perhaps you could build a PHP IRC Client, so please follow some of the notes below for guidance. This bot is [...]]]></description>
			<content:encoded><![CDATA[<h1>Description</h1>
<p>Simple PHP IRC Bot, is a simple PHP IRC Bot class designed to connect to an IRC server, run a few simple commands.  This script is designed and intended to be built upon, perhaps you could build a PHP IRC Client, so please follow some of the notes below for guidance. This bot is based off a PHP IRC Bot tutorial done on our sister site. In the coming weeks more specialized PHP IRC Bots will be made from this script. It will be expanded and modified for many uses including <a href="http://www.wildphp.com/scripts/simple-php-irc-logger/"><strong>channel logging</strong></a> and <strong>channel moderation</strong>, so don&#8217;t forget to <a href="http://feeds.feedburner.com/wildphp">subscribe</a>.</p>
<h1>Warning</h1>
<p>This script uses PHP sockets, and most shared hosting and some servers have it disabled by default. This script runs continuously so it is not recommended to run on shared hosting accounts. We recommend you run it locally using the instructions below.</p>
<h1>Installation</h1>
<ol>
<li>Download or copy paste the script from this page</li>
<li>(Optional) If downloaded rename the file to bot.php ( Sorry, the blog will only allow me to upload it as bot.txt)</li>
<li>Edit the $config array in the script to the server settings, should be self explanatory</li>
<li>Download and install <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a></li>
<li>Place bot.php in the htdocs folder of your XAMPP installation</li>
<li>Don&#8217;t forget to start the Apache server by pressing the start button in the XAMPP Control Panel</li>
<li>Go to <a href="http://localhost/bot.php">http://localhost/bot.php</a>, and the bot should connect and join the channel you specified in about 30 seconds</li>
</ol>
<h1>Code</h1>
<p>Download <a href="http://www.wildphp.com/wp-content/uploads/2010/03/bot.txt" target="_blank">bot.txt</a> (Right click, Save As&#8230;)</p>
<p>or</p>
<pre class="brush: php">

&lt;?php

/**
* Simple PHP IRC Bot
*
* PHP Version 5
*
* LICENSE: This source file is subject to Creative Commons Attribution
* 3.0 License that is available through the world-wide-web at the following URI:
* http://creativecommons.org/licenses/by/3.0/.  Basically you are free to adapt
* and use this script commercially/non-commercially. My only requirement is that
* you keep this header as an attribution to my work. Enjoy!
*
* @category   Chat Room Scipt
* @package    Simple PHP IRC Bot
* @author     Super3boy &lt;admin@wildphp.com&gt;
* @copyright  2010, The Nystic Network
* @license    http://creativecommons.org/licenses/by/3.0/
* @link       http://wildphp.com (Visit for updated versions and more free scripts!)
* @version    1.0.0 (Last updated 03-20-2010)
*
*/

//So the bot doesnt stop.
set_time_limit(0);
ini_set(&#039;display_errors&#039;, &#039;on&#039;);

//Sample connection data.
$config = array(
&#039;server&#039; =&gt; &#039;chat.freenode.net&#039;,
&#039;port&#039;   =&gt; 6667,
&#039;channel&#039; =&gt; &#039;#nystic_chat&#039;,
&#039;name&#039;   =&gt; &#039;wildphp-bot&#039;,
&#039;nick&#039;   =&gt; &#039;wildphp-bot&#039;,
&#039;pass&#039;   =&gt; &#039;&#039;,
);

/*
//Set your connection data.
$config = array(
&#039;server&#039; =&gt; &#039;example.com&#039;,
&#039;port&#039;   =&gt; 6667,
&#039;channel&#039; =&gt; &#039;#channel&#039;,
&#039;name&#039;   =&gt; &#039;real name&#039;,
&#039;nick&#039;   =&gt; &#039;user&#039;,
&#039;pass&#039;   =&gt; &#039;pass&#039;,
);
*/

class IRCBot {

//This is going to hold our TCP/IP connection
var $socket;

//This is going to hold all of the messages both server and client
var $ex = array();

/*

Construct item, opens the server connection, logs the bot in
@param array

*/

function __construct($config)

{
$this-&gt;socket = fsockopen($config[&#039;server&#039;], $config[&#039;port&#039;]);
$this-&gt;login($config);
$this-&gt;main($config);
}

/*

Logs the bot in on the server
@param array

*/

function login($config)
{
$this-&gt;send_data(&#039;USER&#039;, $config[&#039;nick&#039;].&#039; wildphp.com &#039;.$config[&#039;nick&#039;].&#039; :&#039;.$config[&#039;name&#039;]);
$this-&gt;send_data(&#039;NICK&#039;, $config[&#039;nick&#039;]);
$this-&gt;join_channel($config[&#039;channel&#039;]);
}

/*

This is the workhorse function, grabs the data from the server and displays on the browser

*/

function main($config)
{
$data = fgets($this-&gt;socket, 256);

echo nl2br($data);

flush();

$this-&gt;ex = explode(&#039; &#039;, $data);

if($this-&gt;ex[0] == &#039;PING&#039;)
{
$this-&gt;send_data(&#039;PONG&#039;, $this-&gt;ex[1]); //Plays ping-pong with the server to stay connected.
}

$command = str_replace(array(chr(10), chr(13)), &#039;&#039;, $this-&gt;ex[3]);

switch($command) //List of commands the bot responds to from a user.
{
case &#039;:!join&#039;:
$this-&gt;join_channel($this-&gt;ex[4]);
break;
case &#039;:!part&#039;:
$this-&gt;send_data(&#039;PART &#039;.$this-&gt;ex[4].&#039; :&#039;, &#039;Wildphp.com Free IRC Bot Script&#039;);
break;

case &#039;:!say&#039;:
$message = &quot;&quot;;
for($i=5; $i &lt;= (count($this-&gt;ex)); $i++)
{
$message .= $this-&gt;ex[$i].&quot; &quot;;
}

$this-&gt;send_data(&#039;PRIVMSG &#039;.$this-&gt;ex[4].&#039; :&#039;, $message);
break;

case &#039;:!restart&#039;:
echo &quot;&lt;meta http-equiv=\&quot;refresh\&quot; content=\&quot;5\&quot;&gt;&quot;;
exit;
case &#039;:!shutdown&#039;:
$this-&gt;send_data(&#039;QUIT&#039;, &#039;Wildphp.com Free IRC Bot Script&#039;);
exit;
}

$this-&gt;main($config);
}

function send_data($cmd, $msg = null) //displays stuff to the broswer and sends data to the server.
{
if($msg == null)
{
fputs($this-&gt;socket, $cmd.&quot;\r\n&quot;);
echo &#039;&lt;strong&gt;&#039;.$cmd.&#039;&lt;/strong&gt;&lt;br /&gt;&#039;;
} else {

fputs($this-&gt;socket, $cmd.&#039; &#039;.$msg.&quot;\r\n&quot;);
echo &#039;&lt;strong&gt;&#039;.$cmd.&#039; &#039;.$msg.&#039;&lt;/strong&gt;&lt;br /&gt;&#039;;
}

}

function join_channel($channel) //Joins a channel, used in the join function.
{

if(is_array($channel))
{
foreach($channel as $chan)
{
$this-&gt;send_data(&#039;JOIN&#039;, $chan);
}

} else {
$this-&gt;send_data(&#039;JOIN&#039;, $channel);
}
}
}

//Start the bot
$bot = new IRCBot($config);
?&gt;
</pre>
<h1>Features and Functions</h1>
<ul>
<li>!join #channel &#8211; Joins the specified IRC channel</li>
<li>!part #channel &#8211; Leaves the specified IRC channel</li>
<li>!say #channel Message &#8211; Says message in the specified IRC channel</li>
<li>!restart &#8211; Quits and restarts the script. (Helpful while testing the script)</li>
<li>!shutdown &#8211; Quits and stops the script.</li>
</ul>
<p>Usage and output:</p>
<blockquote><p>&lt;random-user&gt; !say #nystic_chat hello there<br />
&lt;wildphp-bot&gt; hello there</p></blockquote>
<h1><strong>Code Lines of Note</strong></h1>
<ul>
<li>Lines 24 &#8211; 48: This is where you set your connection data</li>
<li>Line 101: Prints all the output you see on the screen</li>
<li>Line 115-140: Contains all commands</li>
<li>Line 180: Starts the bot</li>
</ul>
<h1>Help/Support</h1>
<p>If you are having any problems with the PHP bot, need help extending it, or just have an idea, feel free to make a post on <a href="http://wildphp.com/forum">our forum</a>.</p>
<h1>Extensions</h1>
<p>Coding.layne build his own version of this PHP Bot. You can take a look at it <a href="https://bitbucket.org/pogosheep/irc-bot">here</a>.</p>
<h1>Conclusion</h1>
<p>Thanks for trying out our PHP IRC bot. If their are any bugs in the code <a href="/contact/">please let us know</a> right away. Also thanks to <a href="http://acidavengers.co.uk/">KillerAuzzie</a> for the for <a href="http://acidavengers.co.uk/code/php/creating-a-php-based-irc-bot/">tutorial</a>/basecode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/scripts/simple-php-irc-bot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Final Code Challenge</title>
		<link>http://www.wildphp.com/basics/final-code-challenge/</link>
		<comments>http://www.wildphp.com/basics/final-code-challenge/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:46:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=178</guid>
		<description><![CDATA[Looks like our teaching time is coming to a close. You have gone from not knowing what PHP is to well versed. You must pass one final test before you are a true PHP Master! Questions Q: What is the purpose of an HTML form? Show Answer &#9660; HTML forms allow us to submit values [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like our teaching time is coming to a close. You have gone from not knowing what PHP is to well versed. You must pass one final test before you are a true PHP Master!</p>
<h1>Questions</h1>
<p>Q: What is the purpose of an HTML form?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1736528479'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1736528479' style='display:none;'>
<p>HTML forms allow us to submit values to PHP which we can process.</p>
</div>
<p>Q: What are the two types of data that a form can send?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1846569497'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1846569497' style='display:none;'>
<p>POST and GET data.</p>
</div>
<p>Q: What are the two types of data that a form can send?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1388744879'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1388744879' style='display:none;'>
<p>POST and GET data.</p>
</div>
<p>Q: Which method of sending data sends the data via the URL?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID2008405041'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID2008405041' style='display:none;'>
<p>GET.</p>
</div>
<p>Q: Which method is best for sending secure information like passwords?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1007100355'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1007100355' style='display:none;'>
<p>The POST method, because if you used the GET method you would see your password in the URL!</p>
</div>
<h1>Programming Projects</h1>
<p>Project One: Write a HTML form and PHP script that takes someones order.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1057501738'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1057501738' style='display:none;'>
<pre class="brush: html">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Final Code Challenge&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form action=&quot;index.php&quot; method=&quot;post&quot;&gt;
What drink do you want?: &lt;input type=&quot;text&quot; name=&quot;drink&quot; /&gt;&lt;br/&gt;
What do you want to eat?: &lt;input type=&quot;text&quot; name=&quot;eat&quot; /&gt;&lt;br/&gt;
What would you like for dessert: &lt;input type=&quot;text&quot; name=&quot;dessert&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<pre class="brush: php">
&lt;?php
echo &quot;To drink you would like &quot;.$_POST[&quot;drink&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;To eat you would like &quot;.$_POST[&quot;eat&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;For dessert you would like &quot;.$_POST[&quot;dessert&quot;].&quot;&lt;br/&gt;&quot;;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>To drink you would like coke<br />
To eat you would like pizza<br />
For dessert you would like cookies</p></blockquote>
</div>
<p>Project Two: Use the GET method to break down the following statement &#8220;?one=you&amp;two=have&amp;three=done&amp;four=it&#8221;. (Add it to the end of the URL of the page)</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1812678860'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1812678860' style='display:none;'>
<pre class="brush: php">

&lt;?php

$one = $_GET[&quot;one&quot;];
$two = $_GET[&quot;two&quot;];
$three = $_GET[&quot;three&quot;];
$four = $_GET[&quot;four&quot;];

echo $one.&quot; &quot;.$two.&quot; &quot;.$three.&quot; &quot;.$four;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>you have done it</p></blockquote>
</div>
<h1>Conclusion</h1>
<p>Well that concludes our brief introduction to PHP. There is so much more to learn, so stick around for more. Don&#8217;t forget to subscribe on the right of the page. If you have any requests for tutorials or scripts, please let us know in the <a href="http://www.wildphp.com/forum/#/feedback/">feedback section</a> of the <a href="http://www.wildphp.com/forum/">forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/final-code-challenge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grabbing $_GET</title>
		<link>http://www.wildphp.com/basics/grabbing-get/</link>
		<comments>http://www.wildphp.com/basics/grabbing-get/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:43:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=174</guid>
		<description><![CDATA[Ah, another one of those choose one or the other they both do the same thing. We can use the same HTML code, but change the method to GET. &#60;html&#62; &#60;head&#62; &#60;title&#62;Flipping Forms Tutorial&#60;/title&#62; &#60;/head&#62; &#60;body&#62; The following is a form: &#60;br/&#62; &#60;form action=&#34;index.php&#34; method=&#34;get&#34;&#62; What is your favorite book?: &#60;input type=&#34;text&#34; name=&#34;book&#34; /&#62;&#60;br/&#62; What [...]]]></description>
			<content:encoded><![CDATA[<p>Ah, another one of those choose one or the other they both do the same thing. We can use the same HTML code, but change the method to <strong>GET</strong>.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form: &lt;br/&gt;

&lt;form action=&quot;index.php&quot; method=&quot;get&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;&lt;br/&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;&lt;br/&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now the difference between GET and POST is a matter of visibility. When we hit the submit the POST data &#8220;magically&#8221; goes to the next page. With GET the data is put on the end of URL. When you hit submit you should see something like this on the end of your URL <strong>?book=Harry+Potter&amp;movie=Star+Wars&amp;website=WildPHP+of+Course!</strong> .To print out the variables like last time we just use $_GET instead of $_POST:</p>
<p>Printed Results:</p>
<p>&lt;?php<br />
//Print out our GET Data<br />
echo &#8220;Favorite Book: &#8220;.$_GET["book"];<br />
echo &#8220;Favorite Movie: &#8220;.$_GET["movie"];<br />
echo &#8220;Favorite Movie: &#8220;.$_GET["website"];<br />
?&gt;</p>
<p>Sample Output:</p>
<blockquote><p>Favorite Book: Harry Potter<br />
Favorite Movie: Star Wars<br />
Favorite Website: WildPHP of Course!</p></blockquote>
<p>Now that the data is viewable in the URL it probably won&#8217;t be the best idea to send passwords or sensitive data via GET. GET however can be very useful because we can pass information to PHP without having to fill out a form. If you look above at the URL you are at right now you can see GET in use. Using the info in the URL, PHP knows what post to pull up.</p>
<p>If you want to create a GET variable in a URL just follow this simple format: <strong>?varname=value&amp;varname2=value2.</strong> Notice that it always starts with a question mark, and additional values can be added with an ampersand(&amp;).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/grabbing-get/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pasting $_POST</title>
		<link>http://www.wildphp.com/basics/pasting-post/</link>
		<comments>http://www.wildphp.com/basics/pasting-post/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 05:13:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=176</guid>
		<description><![CDATA[In the last tutorial we brushed up on our HTML skills. Lets take the code from the last tutorial, and make a small edit. &#60;html&#62; &#60;head&#62; &#60;title&#62;Flipping Forms Tutorial&#60;/title&#62; &#60;/head&#62; &#60;body&#62; The following is a form: &#60;br/&#62; &#60;form action=&#34;index.php&#34; method=&#34;post&#34;&#62; What is your favorite book?: &#60;input type=&#34;text&#34; name=&#34;book&#34; /&#62;&#60;br/&#62; What is your favorite movie?: &#60;input [...]]]></description>
			<content:encoded><![CDATA[<p>In the last tutorial we brushed up on our HTML skills. Lets take the code from the last tutorial, and make a small edit.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form: &lt;br/&gt;

&lt;form action=&quot;index.php&quot; method=&quot;post&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;&lt;br/&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;&lt;br/&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;&lt;br/&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>If you didn&#8217;t notice the slight change I made was <strong>method=&#8221;post&#8221;</strong>. This specifies the type of data our form should send. Now on to the PHP. Putting some text in box and hitting submit is not going to do us much good, so let&#8217;s capture it and print it out. Put this PHP code under the &lt;/form&gt; tag.</p>
<pre class="brush: php">

Printed Results:&lt;br/&gt;

&lt;?php
//Print out our Post Data
echo &quot;Favorite Book: &quot;.$_POST[&quot;book&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;Favorite Movie: &quot;.$_POST[&quot;movie&quot;].&quot;&lt;br/&gt;&quot;;
echo &quot;Favorite Website: &quot;.$_POST[&quot;website&quot;].&quot;&lt;br/&gt;&quot;;
?&gt;
</pre>
<p>Sample Output:</p>
<blockquote><p>Favorite Book: Harry Potter<br />
Favorite Movie: Star Wars<br />
Favorite Website: WildPHP of Course!</p></blockquote>
<p>As you can see from the code we get the post data and print it out once you hit submit. The simple $_POST["var name"] statement allows us to do that.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/pasting-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flipping Forms</title>
		<link>http://www.wildphp.com/basics/flipping-forms/</link>
		<comments>http://www.wildphp.com/basics/flipping-forms/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 04:31:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=172</guid>
		<description><![CDATA[For this series of tutorials I said you needed to know HTML. Since I am a nice guy I will teach you the limited HTML we need to know for our next two tutorials. Let&#8217;s start with a basic HTML document and then go from there. &#60;html&#62; &#60;head&#62; &#60;title&#62;Flipping Forms Tutorial&#60;/title&#62; &#60;/head&#62; &#60;body&#62; The following [...]]]></description>
			<content:encoded><![CDATA[<p>For this series of tutorials I said you needed to know HTML. Since I am a nice guy I will teach you the limited HTML we need to know for our next two tutorials. Let&#8217;s start with a basic HTML document and then go from there.</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form:
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>In previous tutorials we have manually entered our integers and strings. For this we needed access to our PHP file to change the values. This would not be particularly helpful to a typical user on your website. HTML forms allow us to submit values to PHP which we can process. Let&#8217;s make a simple form</p>
<pre class="brush: html">

&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Flipping Forms Tutorial&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
The following is a form:

&lt;form action=&quot;index.php&quot;&gt;
What is your favorite book?: &lt;input type=&quot;text&quot; name=&quot;book&quot; /&gt;
What is your favorite movie?: &lt;input type=&quot;text&quot; name=&quot;movie&quot; /&gt;
What is your favorite website?: &lt;input type=&quot;text&quot; name=&quot;website&quot; /&gt;
&lt;input type=&quot;submit&quot; /&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Let&#8217;s go through the HTML one part at a time. If you are already well versed in HTML you should be able to skip this tutorial, and move on to the next one on POST.</p>
<p><strong>Action=&#8221;index.php&#8221;</strong> &#8211; This line is the document that you are directed to after you hit the submit button. I am assuming you are still using index.php to run your PHP code .If you are not, you will have to modify it to the one you are using. You can direct it to a completely different one to run your PHP code there as well (more in the next tutorial).</p>
<p><strong>&lt;input type=&#8221;text&#8221; name=&#8221;book&#8221; /&gt;</strong> &#8211; In this line we have the textbox type which is text for textbox. We also have a name which is very important. Follow the same rules as the PHP variable names to keep everything simple. We will use this name to access it in PHP so keep it simple and short.</p>
<p><strong>&lt;input type=&#8221;submit&#8221; /&gt;</strong> &#8211; Our submit button. You can also add value=&#8221;Your Text&#8221;, to change the text from &#8220;Submit Query&#8221;.</p>
<p>Now that you have a little more knowledge with PHP forms, we can move on to more fun things!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/flipping-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Challenge 3</title>
		<link>http://www.wildphp.com/basics/code-challenge-three/</link>
		<comments>http://www.wildphp.com/basics/code-challenge-three/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 03:36:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=170</guid>
		<description><![CDATA[Me again! I hope you are having fun with loops and arrays, so let’s test your knowledge. Questions Q: What is a loop? Show Answer &#9660; A loop allows for the repeating of portions of code over and over again. Q: What is the syntax when using a For loop? Show Answer &#9660; &#60;?php for [...]]]></description>
			<content:encoded><![CDATA[<p>Me again! I hope you are having fun with loops and arrays, so let’s test your knowledge.</p>
<h1>Questions</h1>
<p>Q: What is a loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1904733787'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1904733787' style='display:none;'>
<p>A loop allows for the repeating of portions of code over and over again.</p>
</div>
<p>Q: What is the syntax when using a For loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID489626617'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID489626617' style='display:none;'>
<pre class="brush: php">

&lt;?php
for ( counting var; conditional statement; increment var)
{
//code
}
?&gt;
</pre>
</div>
<p>Q: What is the syntax for a While loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1196894294'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1196894294' style='display:none;'>
<pre class="brush: php">

&lt;?php
while ( conditional statement)
{
//code
}
?&gt;
</pre>
</div>
<p>Q: What is an infinite loop?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID1926438022'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID1926438022' style='display:none;'>
<p>The loop condition is never met and the loop keeps repeating forever.</p>
</div>
<p>Q: What is an array index?</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID433923534'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID433923534' style='display:none;'>
<p>A location in an array with an individual value.</p>
</div>
<h1>Programming Projects</h1>
<p>Project One: Write a program that prints out “I Love WildPHP.com!” 10 times. Use <strong>While</strong> and <strong>For</strong> loops.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID467224744'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID467224744' style='display:none;'>
<pre class="brush: php">

&lt;?php
//For Loop
for($i=1; $i&lt;=5; $i++)
{
echo &quot;I Love WildPHP.com! &quot;;
}

//While Loop
$i=1;
while($i&lt;=5)
{
echo &quot;I Love WildPHP.com! &quot;;
$i++;
}
?&gt;
</pre>
</div>
<p>Project Two: Write a loop that will add all the numbers in the following integer array: 22, 56, 7, 32, and 11.</p>
<p><a href="javascript:void(null);" onclick="s_toggleDisplay(document.getElementById('SID862794652'), this, 'Show Answer &#9660;', 'Hide Answer &#9650;');">Show Answer &#9660;</a></p>
<div id='SID862794652' style='display:none;'>
<pre class="brush: php">

&lt;?php
//Declare Array
$numbers = array(22, 56, 7, 32, 11);

//Sum Variable
$sum = 0;

//For Loop
for($i=0; $i&lt;5; $i++)
{
$sum += $numbers[$i];
}

echo &quot;The sum is &quot;.$sum;
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>The sum is 128</p></blockquote>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/code-challenge-three/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Awesome Arrays</title>
		<link>http://www.wildphp.com/basics/awesome-arrays/</link>
		<comments>http://www.wildphp.com/basics/awesome-arrays/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 01:20:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Basics]]></category>

		<guid isPermaLink="false">http://www.wildphp.com/?p=168</guid>
		<description><![CDATA[At the start of this series of tutorial we learned how to use variable. As you already know variable store information for use for editing and later use. So what happens when you need use a bunch of variable?  Let&#8217;s say for example you wanted to store a bunch of ice cream flavors, lets say [...]]]></description>
			<content:encoded><![CDATA[<p>At the start of this series of tutorial we learned how to use variable. As you already know variable store information for use for editing and later use. So what happens when you need use a bunch of variable?  Let&#8217;s say for example you wanted to store a bunch of ice cream flavors, lets say 8. Using what we learned up to this would take a few lines because we would need to create a new variable to store each new flavor. This is where <strong>arrays</strong> come in handy.</p>
<p>Arrays can store all types of values from string to integers to many different types we have yet to go over. Lets try out a simple array before we move on to our example:</p>
<pre class="brush: php">

&lt;?php
//One way to declare an array
$apartment = array(&quot;Ground Floor&quot;,&quot;Floor 1&quot;,&quot;Floor 2&quot;,&quot;Floor 3&quot;);

//Other way to declare an array
$apartment[0]=&quot;Ground Floor&quot;;
$apartment[1]=&quot;Floor 1&quot;;
$apartment[2]=&quot;Floor 2&quot;;
$apartment[3]=&quot;Floor 3&quot;;

//Print out a floor name
echo $apartment[2];
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>Floor 2</p></blockquote>
<p>Think of an array as a stack of variables. Instead of creating a bunch of variables, we can simply create an array. The individual values in an array, by it&#8217;s index. If your confused you can think of an array as a building with individual values on each floor. If we specify we want to go to index or &#8220;floor&#8221; 0, remember we always start from zero in PHP, we might find a stored value like &#8220;chocolate.&#8221; If we where to go to 6th index or &#8220;floor&#8221; we could find a value like vanilla.</p>
<pre class="brush: php">

&lt;?php
//Declare our array
$flavors = array(&quot;Chocolate &quot;, &quot;Strawberry &quot;, &quot;Butter pecan &quot;, &quot;Neapolitan &quot;,
&quot;Vanilla fudge ripple &quot;, &quot;French vanilla &quot;, &quot;Vanilla &quot;, &quot;Cookies and cream &quot;);

//Edit a flavor
$flavors[0] = &quot;Chocolate chip &quot;;

//Print our flavors
echo &quot;Our Flavors: &quot;;
for($i=0; $i&lt;=7; $i++)
{
echo $flavors[$i];
}
?&gt;
</pre>
<p>Output:</p>
<blockquote><p>Our Flavors: Chocolate chip Strawberry Butter pecan Neapolitan Vanilla fudge ripple French vanilla Vanilla Cookies and cream</p></blockquote>
<p>Wwe can do the same thing more efficiently with arrays. We can easily add other ice cream flavor, and have it print out for us without adding additional lines.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wildphp.com/basics/awesome-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

