<?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>Jared Heinrichs &#187; PHP</title>
	<atom:link href="http://jaredheinrichs.com/category/programming/php/feed" rel="self" type="application/rss+xml" />
	<link>http://jaredheinrichs.com</link>
	<description>A Winnipeg &#34;How to&#34; Blog on Software and Technology</description>
	<lastBuildDate>Sat, 19 May 2012 22:43:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Fatal error: Cannot redeclare functionX()</title>
		<link>http://jaredheinrichs.com/php-fatal-error-cannot-redeclare-functionx.html</link>
		<comments>http://jaredheinrichs.com/php-fatal-error-cannot-redeclare-functionx.html#comments</comments>
		<pubDate>Mon, 21 Dec 2009 14:28:02 +0000</pubDate>
		<dc:creator>Jared Heinrichs</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jaredheinrichs.com/php-fatal-error-cannot-redeclare-functionx.html</guid>
		<description><![CDATA[You might get an error similar to this when writing a php application: Fatal error: Cannot redeclare functioX() in C:\Users\Jared\htdocs\list.php on line 24. The reason why you are getting this is you created a function that is named the same &#8230; <a href="http://jaredheinrichs.com/php-fatal-error-cannot-redeclare-functionx.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You might get an error similar to this when writing a php application: <strong>Fatal error</strong>: Cannot redeclare functioX() in <strong>C:\Users\Jared\htdocs\list.php</strong> on line <strong>24. </strong></p>
<p><span id="more-2114"></span></p>
<p>The reason why you are getting this is you created a function that is named the same as a previously declaired function where you created it your self or one that is built into PHP. In my case I had created a function called “readFile($file)”. I didn’t realize that there was already a PHP function that had the same name.</p>
<p>How to resolve the error:</p>
<p>The only way to resolve this issue is by renaming the function you just created to something else. In mycase I could rename the function to: “jaredReadFile($file)”.</p>
<p>Hope this helped you resolve the PHP Fatal error: Cannot redeclare functionX()!</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredheinrichs.com/php-fatal-error-cannot-redeclare-functionx.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; All about arrays (Part 1 of 3)</title>
		<link>http://jaredheinrichs.com/php-all-about-arrays-part-1-of-3.html</link>
		<comments>http://jaredheinrichs.com/php-all-about-arrays-part-1-of-3.html#comments</comments>
		<pubDate>Sat, 19 Dec 2009 06:20:06 +0000</pubDate>
		<dc:creator>Jared Heinrichs</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jaredheinrichs.com/php-all-about-arrays-part-1-of-3.html</guid>
		<description><![CDATA[This post will help you understand what an array is and how it is used. In this three part series I will will go over: What is an array Creating arrays Testing for an array Adding and removing array elements &#8230; <a href="http://jaredheinrichs.com/php-all-about-arrays-part-1-of-3.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post will help you understand what an array is and how it is used.</p>
<p><span id="more-2084"></span></p>
<p>In this three part series I will will go over:</p>
<ul>
<li>What is an array</li>
<li>Creating arrays</li>
<li>Testing for an array</li>
<li>Adding and removing array elements</li>
<li>Locating array elements</li>
<li>Traversing Arrays</li>
<li>Determining array Size and element uniqueness</li>
<li>Sorting arrays</li>
<li>Merging, slicing, splicing and dissecting arrays</li>
</ul>
<h2>What is an array?</h2>
<p>A traditional array is defined as a group of items that share certain characteristics such as similarity and type.</p>
<ol>
<li><em>Examples of Similarity might be something like “car models”, “baseball teams” or “types of fruit”.</em></li>
<li><em>Examples of types might be something like “string” or “integers”</em></li>
<li>*NOTE* The items DON’T have to groups of similar items.</li>
</ol>
<p> </p>
<p>There are two main parts of an array. The array is made up of a key and a value. While “Value” is pretty obvious the key is something a lot of beginning programmer have an issue with. Keys can be one of two types. Numerical or Associative. Associative keys ten to bear some relation to the value other then its array position.</p>
<p>An example of a numeric array being defined:</p>
<pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">&lt;?</span>php</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[0] = "<span style="color: #8b0000;">BC</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[1] = "<span style="color: #8b0000;">Alberta</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[2] = "<span style="color: #8b0000;">Saskatchewan</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[3] = "<span style="color: #8b0000;">Ontario</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">?&gt;</span></pre>
</pre>
<p> </p>
<p>The key’s in this example are “0”, “1”, “2”, “3”.</p>
<p>An example of an Associative array being defined:</p>
<pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">&lt;?</span>php</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[BC] = "<span style="color: #8b0000;">Vancouver</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[AB] = "<span style="color: #8b0000;">Calgary</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[SK] = "<span style="color: #8b0000;">Regina</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[MB] = "<span style="color: #8b0000;">Winnipeg</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">    $provinces[ON] = "<span style="color: #8b0000;">Toronto</span>";</pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;"><span style="color: #0000ff;">?&gt;</span></pre>
</pre>
<p> </p>
<p>Notice now how I used strings instead of numbers for the key identifier? The key’s also make more sense then using 0,1,2 etc.</p>
<h2>Outputting Arrays</h2>
<p>The easiest way of quickly outputting an array in php is by using the print_r() function. The output isn’t very nice but it allows you to see what’s all in the array. To use the print_r() function you would type:</p>
<pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">print_r($provinces);</pre>
</pre>
<p> </p>
<p>Here’s an example of the output of associative array above using print_r() function.</p>
<pre>
<pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px;">Array ( [BC] =&gt; Vancouver [AB] =&gt; Calgary [SK] =&gt; Regina [MB] =&gt; Winnipeg [ON] =&gt; Toronto )</pre>
</pre>
<p> </p>
<p>sd</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredheinrichs.com/php-all-about-arrays-part-1-of-3.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>$_SERVER(&#8216;REMOTE_ADDR&#8217;) Fatal error: Function name must be a string in:</title>
		<link>http://jaredheinrichs.com/_serverremote_addr-fatal-error-function-name-must-be-a-string-in.html</link>
		<comments>http://jaredheinrichs.com/_serverremote_addr-fatal-error-function-name-must-be-a-string-in.html#comments</comments>
		<pubDate>Thu, 03 Dec 2009 17:10:12 +0000</pubDate>
		<dc:creator>Jared Heinrichs</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jaredheinrichs.com/_serverremote_addr-fatal-error-function-name-must-be-a-string-in.html</guid>
		<description><![CDATA[This will be a Homer Simpson “doh” moment for you as much as it was for me. When calling Super Global Variables you have to use “[]” instead of “()”. The code should look something like this: echo "Your IP &#8230; <a href="http://jaredheinrichs.com/_serverremote_addr-fatal-error-function-name-must-be-a-string-in.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->This will be a Homer Simpson “doh” moment for you as much as it was for me. When calling Super Global Variables you have to use “[]” instead of “()”.</p>
<p>The code should look something like this:</p>
<pre class="csharpcode">echo <span class="str">"Your IP address is: "</span> . $_SERVER[<span class="str">'REMOTE_ADDR'</span>];</pre>
<p>The reason why you have to use [] instead of () is that the $_SERVER variable is an array and not an object/function. Hope this helps!</p>
]]></content:encoded>
			<wfw:commentRss>http://jaredheinrichs.com/_serverremote_addr-fatal-error-function-name-must-be-a-string-in.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to setup the Netbeans IDE with PHP and MySQL Support.</title>
		<link>http://jaredheinrichs.com/how-to-setup-the-netbeans-ide-with-php-and-mysql-support.html</link>
		<comments>http://jaredheinrichs.com/how-to-setup-the-netbeans-ide-with-php-and-mysql-support.html#comments</comments>
		<pubDate>Tue, 24 Nov 2009 02:18:27 +0000</pubDate>
		<dc:creator>Jared Heinrichs</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[How To]]></category>

		<guid isPermaLink="false">http://jaredheinrichs.com/how-to-setup-the-netbeans-ide-with-php-and-mysql-support.html</guid>
		<description><![CDATA[This post will go over setting up my new favorite IDE. Up until now I have been using Nusphere PHPed IDE which I still think is much better at certain things but considering the price tag of what I am &#8230; <a href="http://jaredheinrichs.com/how-to-setup-the-netbeans-ide-with-php-and-mysql-support.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post will go over setting up my new favorite IDE. Up until now I have been using <a href="http://www.nusphere.com/" target="_blank">Nusphere PHPed IDE</a> which I still think is much better at certain things but considering the price tag of what I am about to show you I think most people could live with the differences.</p>
<p><span id="more-1883"></span></p>
<p>There are a few things that I recommend that you do. The first and should be most obvious thing that you will need first is a web server setup. If you don’t have an environment setup you can always download XAMPP which is a collect of applications you can put on your local development machine and not have to worry about manually setting up. I’ve written a <a href="http://jaredheinrichs.com/xampp-pear.html" target="_blank">How to Install XAMPP with Pear</a> on another blog post. Check it out.</p>
<p>Now that we are sure we have the backend setup we now want to make sure that we have the front end setup. The front end will comprise of Netbeans IDE.</p>
<p>1.) <a href="http://netbeans.org/downloads/index.html" target="_blank">Download Netbeans IDE</a>.</p>
<p>2.) Pick what version you want to install. I recommend the “PHP Version”.</p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image28.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb22.png" border="0" alt="image" width="574" height="405" /></a></p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image29.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb23.png" border="0" alt="image" width="577" height="83" /></a></p>
<p>This screen might fail if you don’t have JRE installed. </p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image30.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb24.png" border="0" alt="image" width="583" height="410" /></a></p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image31.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb25.png" border="0" alt="image" width="580" height="406" /></a></p>
<p>When you log into Netbeans for the first time there will most likely be some updates. The program should alert you to them at the bottom right corner of the window.</p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image32.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb26.png" border="0" alt="image" width="235" height="129" /></a></p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image33.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb27.png" border="0" alt="image" width="524" height="447" /></a></p>
<p>The program will need to be restarted with almost all updates.</p>
<p>Since I am taking an Object Oriented Programming (OOP) course right now my example will be based on that. To get to the files on the web server I will type <a href="http://localhost/oop">http://localhost/oop</a> to get to it. The next thing to do is to setup your first Project.</p>
<p>To create a new project click on “New Project” and point it to where you installed XAMPP. In my case it is located under C:\Users\Jared\xampp\htdocs\oop</p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image34.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb28.png" border="0" alt="image" width="543" height="164" /></a></p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image35.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb29.png" border="0" alt="image" width="644" height="421" /></a></p>
<p>To setup MySQL you must click on the “Services” tab</p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image36.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb30.png" border="0" alt="image" width="458" height="264" /></a></p>
<p>and then fill out the information that you need to connect. Make sure that you setup a Database and user that you log in with.</p>
<p><a href="http://jaredheinrichs.com/wp-content/uploads/2009/11/image37.png"><img style="display: inline; border: 0px;" title="image" src="http://jaredheinrichs.com/wp-content/uploads/2009/11/image_thumb31.png" border="0" alt="image" width="509" height="337" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jaredheinrichs.com/how-to-setup-the-netbeans-ide-with-php-and-mysql-support.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework PHP Coding Standard Overview</title>
		<link>http://jaredheinrichs.com/zend-framework-php-coding-standard-overview.html</link>
		<comments>http://jaredheinrichs.com/zend-framework-php-coding-standard-overview.html#comments</comments>
		<pubDate>Fri, 04 Sep 2009 15:03:15 +0000</pubDate>
		<dc:creator>Jared Heinrichs</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://jaredheinrichs.com/zend-framework-php-coding-standard-overview.html</guid>
		<description><![CDATA[This post will go over the “Zend Framework PHP Coding Standard” in a very brief overview. Like most things I tend to use this website as reminders to myself. I hope this helps you as well Naming Conventions Use class &#8230; <a href="http://jaredheinrichs.com/zend-framework-php-coding-standard-overview.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This post will go over the “Zend Framework PHP Coding Standard” in a very brief overview. Like most things I tend to use this website as reminders to myself. I hope this helps you as well <img src='http://jaredheinrichs.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p> <span id="more-1553"></span>
<p><strong>Naming Conventions</strong></p>
<ol>
<li>Use class names that map to the directory of the structure in which the class is stored by prefixing the class name of each directory followed by an underscore. All my personal classes might be saved to the “Jh” Directory. So the class in “Validator.php” is called Jh_Validator.</li>
<li>Capitalize on the first letter of each word in the file and directory names.</li>
<li>Use descriptive names for methods and properties. Where they consist of more then one word, each additional name should begin with a capital letter. ie. (validateFirstName)</li>
<li>Begin the names of private and protected properties with an underscore.</li>
<li>Use UPPERCASE only for constants. Separate each word with an underscore.</li>
</ol>
<p><strong>Coding Style</strong></p>
<ol>
<li>Always use the full opening PHP tag. “&lt;?php”</li>
<li>Omit closing PHP tag “?&gt;” in files that contain only php code. This prevents whitespace triggering the “headers already sent” error when using includes.</li>
<li>Indent 4 spaces</li>
<li>Restrict lins to a maximum of 80 characters</li>
<li>Always use single quotes unless they contain variables to be processed.</li>
<li>Put a space on either side of the concatenation operator “ . “ for readability.</li>
<li>Insert space after comas for readability.</li>
<li>Break Associative arrays into multiple lines. Use white space padding to align both keys and values.</li>
<li>Put open and closing braces of classes and functions on separate lines.</li>
<li>Put the opening brace of conditional statement on the same line as the condition, but the closing brace on a line of its own.</li>
<li>Use PHPDoc formatted comments.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://jaredheinrichs.com/zend-framework-php-coding-standard-overview.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

