<?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>Zend PHP Certification</title>
	<atom:link href="http://zend-php-certification.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://zend-php-certification.com</link>
	<description>My Study Notes</description>
	<lastBuildDate>Mon, 20 May 2013 14:32:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Heredoc Syntax</title>
		<link>http://zend-php-certification.com/2013/05/20/heredoc-syntax/</link>
		<comments>http://zend-php-certification.com/2013/05/20/heredoc-syntax/#comments</comments>
		<pubDate>Mon, 20 May 2013 14:32:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Strings]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[heredoc string]]></category>
		<category><![CDATA[php heredoc]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[php strings]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=56</guid>
		<description><![CDATA[Heredoc is a strange but necessary way to create a complex string. The functionality provided is almost identical to double quoted strings except there are no quotes. The heredoc syntax uses the special operator &#8216;]]></description>
				<content:encoded><![CDATA[<p>Heredoc is a strange but necessary way to create a complex string. The functionality provided is almost identical to double quoted strings except there are no quotes. </p>
<p>The heredoc syntax uses the special operator &#8216;<<<' followed by a user defined identifier. The same identifier on a new line must be used to close the string followed by an optional semicolon. This identifier is restricted by the same rules as a regular variable name.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$what</span> = <span class="st0">&quot;Certification&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> &lt;&lt;&lt;TEXT</div>
</li>
<li class="li1">
<div class="de1">Zend PHP <span class="st0">&quot;$what&quot;</span></div>
</li>
<li class="li2">
<div class="de2">TEXT;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p></p>
<p>This will output &#8216;Zend PHP &#8220;Certification&#8221;&#8216;.<br />
Heredoc syntax can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2013/05/20/heredoc-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stacks, Queues and Sets</title>
		<link>http://zend-php-certification.com/2012/12/21/stacks-queues-and-sets/</link>
		<comments>http://zend-php-certification.com/2012/12/21/stacks-queues-and-sets/#comments</comments>
		<pubDate>Fri, 21 Dec 2012 03:07:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[Array Queues]]></category>
		<category><![CDATA[Array Set]]></category>
		<category><![CDATA[Array Stack]]></category>
		<category><![CDATA[php arrays]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[Queues]]></category>
		<category><![CDATA[Sets]]></category>
		<category><![CDATA[Stacks]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=41</guid>
		<description><![CDATA[Arrays can be used in a number of different ways. This can include stacks, queues, and sets. I personally don&#8217;t use these functions very often but It can&#8217;t hurt to go over them for before taking the Zend Certification exam. Stacks are a Last in, First out (LIFO) structure which means that the first element [...]]]></description>
				<content:encoded><![CDATA[<p>Arrays can be used in a number of different ways. This can include stacks, queues, and sets. I personally don&#8217;t use these functions very often but It can&#8217;t hurt to go over them for before taking the Zend Certification exam.</p>
<p>Stacks are a Last in, First out (LIFO) structure which means that the first element you put on the stack is only available when all other elements are removed. Just like a stack of papers. This is acheived by using the array_push and array_pop functions.</p>
<p>Here is a simple little example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$stack_array</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/array_push"><span class="kw3">array_push</span></a><span class="br0">&#40;</span><span class="re0">$stack_array</span>,<span class="st0">&quot;zend&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//You can add multiple values at once</span></div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/array_push"><span class="kw3">array_push</span></a><span class="br0">&#40;</span><span class="re0">$stack_array</span>,<span class="st0">&quot;php&quot;</span>,<span class="st0">&quot;certification&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$last_in</span> = <a href="http://www.php.net/array_pop"><span class="kw3">array_pop</span></a><span class="br0">&#40;</span><span class="re0">$stack_array</span><span class="br0">&#41;</span>; <span class="co1">//last_in will house &quot;certification&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>The array_push function is very similar to &#8220;$a[] = $value&#8221; and the latter is actually much faster because no function call is made.</p>
<p>Next up is the queue which is a first in first out data structure. Just like a line at a movie theater, the first elements added to the queue get their choice of seats. Queue manipulation is acheived using the array_shift, array_unshift, and any of the functions outlined above.</p>
<p>The array_shift function will remove and return the element from the front of the array and the array_unshift will prepend an element to the front of the array. If both these functions are used together then the array will work like a sort of backwards stack but if array_shift is used with array_push or if array_unshift is used with array_pop then the array will act as a queue.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$stack_array</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>’zend’, ’php’, ’cert’<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$first</span> = <a href="http://www.php.net/array_shift"><span class="kw3">array_shift</span></a><span class="br0">&#40;</span><span class="re0">$stack</span><span class="br0">&#41;</span>; <span class="co1">//$first now houses &#8216;zend&#8217;</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/array_unshift"><span class="kw3">array_unshift</span></a><span class="br0">&#40;</span><span class="re0">$stack</span>, ’dont fail’<span class="br0">&#41;</span>; <span class="co1">//adds &#8216;dont fail&#8217; to the beginning of the array.</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>There are a few functions that mimic set functionality using php arrays. These are array_diff(), array_intersect, array_intersect_key(), array_intersect_assoc(),array_intersect_ukey(), and array_intersect_uassoc().</p>
<p>The function array_diff() is used to compute the difference between two arrays:</p>
<pre lang="php>
$a = array (1, 2, 3);
$b = array (1, 3, 4);
var_dump (array_diff ($a, $b));

//output
array(1) {
  [1]=>
  int(2)
}
</pre>
<p>As you can see, array_diff() causes all the values of $a that do not also appear in $b to returned and everything else is thrown out. There is also an array_diff_key() function which does the same thing but with the array keys, an array_diff_assoc() function which keeps the key=>value pairs, and even array_diff_ukey() and array_diff_uassoc() where we can define our own user-defined callback functions.</p>
<p>The function array_intersect() does something very similar to array_diff() but instead of the difference, this function will return the values that are included in both arrays. There is also an array_intersect_key(), an array_intersect_assoc(), an array_intersect_uassoc(), and an array_intersect_ukey().</p>
<p>So many functions that I will almost never use. I really hope I pass this exam.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/21/stacks-queues-and-sets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Sorting Functions</title>
		<link>http://zend-php-certification.com/2012/12/20/php-sorting-functions/</link>
		<comments>http://zend-php-certification.com/2012/12/20/php-sorting-functions/#comments</comments>
		<pubDate>Thu, 20 Dec 2012 03:26:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[php arrays]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[php sort]]></category>
		<category><![CDATA[php sorting]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[sorting arrays]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[variable length arguments]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=35</guid>
		<description><![CDATA[In all the countless hours I&#8217;ve spent with php, I&#8217;ve maybe used three or four of these sorting functions. I really had no idea that there is a total of eleven functions used for sorting arrays. Anyway, I&#8217;m betting that it may be useful to have these memorized before I take the Zend PHP Certification [...]]]></description>
				<content:encoded><![CDATA[<p>In all the countless hours I&#8217;ve spent with php, I&#8217;ve maybe used three or four of these sorting functions. I really had no idea that there is a total of eleven functions used for sorting arrays. Anyway, I&#8217;m betting that it may be useful to have these memorized before I take the Zend PHP Certification Exam so here is a brief overview of each one.</p>
<p>A lot of the sorting functions have an optional flag that may be used to modify the sorting behavior.<br />
The available flags are:</p>
<p>    SORT_REGULAR &#8211; compare items normally (don&#8217;t change types)<br />
    SORT_NUMERIC &#8211; compare items numerically<br />
    SORT_STRING &#8211; compare items as strings<br />
    SORT_LOCALE_STRING &#8211; compare items as strings, based on the current locale.</p>
<p>All of these functions sort arrays. I don&#8217;re really think it&#8217;s necessary to type out an example for each one but I will go into greater detail about some. Each function will return a boolean which is true on success and false on failure.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/sort"><span class="kw3">sort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This sort function will arrange the elements from lowest to highest.<br />
Array indices do NOT maintain their correlation with the array elements they are associated with.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/rsort"><span class="kw3">rsort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>	This one will arrange the elements from highest to lowest (Reverse Sort).</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/natsort"><span class="kw3">natsort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This sorting function will sort the array alphanumerically. This is more &#8220;natural&#8221; for most people.<br />
Here is a comparison between the regular sort and this natural sort from the <a href='http://www.php.net/manual/en/function.natsort.php' title='php natsort'><br />
php.net site</a>:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$array1</span> = <span class="re0">$array2</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&quot;img12.png&quot;</span>, <span class="st0">&quot;img10.png&quot;</span>, <span class="st0">&quot;img2.png&quot;</span>, <span class="st0">&quot;img1.png&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/asort"><span class="kw3">asort</span></a><span class="br0">&#40;</span><span class="re0">$array1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;Standard sorting<span class="es0">\n</span>&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$array1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/natsort"><span class="kw3">natsort</span></a><span class="br0">&#40;</span><span class="re0">$array2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;<span class="es0">\n</span>Natural order sorting<span class="es0">\n</span>&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$array2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">Which will output:</div>
</li>
<li class="li1">
<div class="de1">Standard sorting</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/array"><span class="kw3">Array</span></a></div>
</li>
<li class="li1">
<div class="de1"><span class="re1"><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span> =&gt; img1.png</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> =&gt; img10.png</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> =&gt; img12.png</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> =&gt; img2.png</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">Natural order sorting</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/array"><span class="kw3">Array</span></a></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#40;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span> =&gt; img1.png</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span> =&gt; img2.png</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span> =&gt; img10.png</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> =&gt; img12.png</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/natcasesort"><span class="kw3">natcasesort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>A case insensitive version of natsort.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/ksort"><span class="kw3">ksort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Sorts an array by the key. It also maintains the key to data correlations.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/krsort"><span class="kw3">krsort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Sorts by key, but in reverse.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/asort"><span class="kw3">asort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This is very similar to the regular sort outlined above except the array indices maintain<br />
their correlation with the array elements they are associated with.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/arsort"><span class="kw3">arsort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> <span class="br0">&#91;</span>, int <span class="re0">$sort_flags</span> = SORT_REGULAR <span class="br0">&#93;</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>	Similar to the asort but reversed.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/usort"><span class="kw3">usort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> , callback <span class="re0">$cmp_function</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This function allows for a custom comparsion function to create different sorting methods. This function should accept only two parameters and return an integer less than, equal to,<br />
or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. Here&#8217;s an example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> cmp<span class="br0">&#40;</span><span class="re0">$a</span>, <span class="re0">$b</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$a</span> == <span class="re0">$b</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="kw1">return</span> <span class="br0">&#40;</span><span class="re0">$a</span> &lt; <span class="re0">$b</span><span class="br0">&#41;</span> ? <span class="nu0">-1</span> : <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="nu0">3</span>, <span class="nu0">2</span>, <span class="nu0">5</span>, <span class="nu0">6</span>, <span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/usort"><span class="kw3">usort</span></a><span class="br0">&#40;</span><span class="re0">$a</span>, <span class="st0">&quot;cmp&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$a</span> <span class="kw1">as</span> <span class="re0">$key</span> =&gt; <span class="re0">$value</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;$key: $value<span class="es0">\n</span>&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">?&gt;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/uasort"><span class="kw3">uasort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> , callback <span class="re0">$cmp_function</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This is similar to usort except the array indices maintain their<br />
correlation with the array elements they are associated with.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">bool <a href="http://www.php.net/uksort"><span class="kw3">uksort</span></a> <span class="br0">&#40;</span> <a href="http://www.php.net/array"><span class="kw3">array</span></a> &amp;<span class="re0">$array</span> , callback <span class="re0">$cmp_function</span> <span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This last sort function works similar to the previous two where you can define a custom comparison function. The difference is that this one works on the keys and it also maintains the correlation with the elements.</p>
<p>There is also a nice comparison of all these functions at <a href="http://www.php.net/manual/en/array.sorting.php" title='array sorting function comparison'>php.net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/20/php-sorting-functions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Array Cursors</title>
		<link>http://zend-php-certification.com/2012/12/15/php-array-cursors/</link>
		<comments>http://zend-php-certification.com/2012/12/15/php-array-cursors/#comments</comments>
		<pubDate>Sat, 15 Dec 2012 02:04:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[php array cursors]]></category>
		<category><![CDATA[php array pointers]]></category>
		<category><![CDATA[php arrays]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[variable length arguments]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=33</guid>
		<description><![CDATA[I don&#8217;t recommend ever using these functions because a foreach loop is so much simpler and shorter. The only reason I&#8217;m writing about these is bacause I have almost never used them and they may just be on the Zend PHP Certification exam. There are a number of functions designed specifically for manipulating array pointers. [...]]]></description>
				<content:encoded><![CDATA[<p>I don&#8217;t recommend ever using these functions because a foreach loop is so much simpler and shorter. The only reason I&#8217;m writing about these is bacause I have almost never used them and they may just be on the Zend PHP Certification exam. </p>
<p>There are a number of functions designed specifically for manipulating array pointers. Most examples that I&#8217;ve seen use these functions during some sort of array iteration. When starting an iteration over an array, the first step is usually to reset the pointer to its initial position using the reset() function. After that, moving forward or backwards by one position is done using prev() and next(). At any given point, we can access the value of the current element using current() and its key using key(). Here&#8217;s a  simple example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$array</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span>’foo’ =&gt; ’bar’, ’baz’, ’bat’ =&gt; <span class="nu0">2</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> displayArray<span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/reset"><span class="kw3">reset</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><a href="http://www.php.net/key"><span class="kw3">key</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> !== <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <a href="http://www.php.net/key"><span class="kw3">key</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> .<span class="st0">&quot;: &quot;</span> .<a href="http://www.php.net/current"><span class="kw3">current</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> . PHP_EOL;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/next"><span class="kw3">next</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>The displayArray function above will display all the values in an array. Reset() is called first to return the internal array pointer to the first element. Next, using a while loop, the current key and value is displayed using the key() and current() functions. Finally, the array pointer is advanced, using next(). </p>
<p>Since you can iterate back-and-forth within an array by using its pointer, you could—in theory—start your iteration from the last element (using the end() function to reset the pointer to the bottom of the array) and then making your way to the beginning:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">3</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/end"><span class="kw3">end</span></a><span class="br0">&#40;</span><span class="re0">$a</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">while</span> <span class="br0">&#40;</span><a href="http://www.php.net/key"><span class="kw3">key</span></a> <span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> !== <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <a href="http://www.php.net/key"><span class="kw3">key</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> .<span class="st0">&quot;: &quot;</span> .<a href="http://www.php.net/current"><span class="kw3">current</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span> . PHP_EOL;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/prev"><span class="kw3">prev</span></a><span class="br0">&#40;</span><span class="re0">$array</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>So I guess that last example may be useful&#8230;but it&#8217;s still probably easier to reverse the entire array and use a foreach.</p>
<p>Anyway, if these are on the Zend PHP Certification exam, I shouldn&#8217;t have a problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/15/php-array-cursors/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Comparing Arrays in PHP</title>
		<link>http://zend-php-certification.com/2012/12/13/comparing-arrays-in-php/</link>
		<comments>http://zend-php-certification.com/2012/12/13/comparing-arrays-in-php/#comments</comments>
		<pubDate>Thu, 13 Dec 2012 01:47:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php array comparison]]></category>
		<category><![CDATA[php arrays]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[variable length arguments]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=26</guid>
		<description><![CDATA[Array-to-array comparison is a relatively rare occurrence in the real world of PHP (at least for me), but it can be performed using a set of operators. Like for other types, the equivalence and identity operators can be used for this purpose: &#160; $a = array &#40;1, 2, 3&#41;; $b = array &#40;1 =&#62; 2, [...]]]></description>
				<content:encoded><![CDATA[<p>Array-to-array comparison is a relatively rare occurrence in the real world of PHP (at least for me), but it can be performed using a set of operators. Like for other types, the equivalence and identity operators can be used for this purpose:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">3</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><span class="nu0">1</span> =&gt; <span class="nu0">2</span>, <span class="nu0">2</span> =&gt; <span class="nu0">3</span>, <span class="nu0">0</span> =&gt; <span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$c</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span>’a’ =&gt; <span class="nu0">1</span>, ’b’ =&gt; <span class="nu0">2</span>, ’c’ =&gt; <span class="nu0">3</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> == <span class="re0">$b</span><span class="br0">&#41;</span>; <span class="co1">// True</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> === <span class="re0">$b</span><span class="br0">&#41;</span>; <span class="co1">// False</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> == <span class="re0">$c</span><span class="br0">&#41;</span>; <span class="co1">// False</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> === <span class="re0">$c</span><span class="br0">&#41;</span>; <span class="co1">// False</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>As you can see, the equivalence operator == returns true if both arrays have the same number of elements with the same values and keys, regardless of their order. The identity operator ===, on the other hand, returns true only if the array contains the same key/value pairs in the same order. </p>
<p>Similarly, the inequality and non-identity operators can determine whether two arrays are different:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><span class="nu0">1</span>, <span class="nu0">2</span>, <span class="nu0">3</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a> <span class="br0">&#40;</span><span class="nu0">1</span> =&gt; <span class="nu0">2</span>, <span class="nu0">2</span> =&gt; <span class="nu0">3</span>, <span class="nu0">0</span> =&gt; <span class="nu0">1</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> != <span class="re0">$b</span><span class="br0">&#41;</span>; <span class="co1">// False</span></div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/var_dump"><span class="kw3">var_dump</span></a> <span class="br0">&#40;</span><span class="re0">$a</span> !== <span class="re0">$b</span><span class="br0">&#41;</span>; <span class="co1">// True</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Once again, the inequality operator only ensures that both arrays contain the same elements with the same keys, whereas the non-identity operator also verifies their position.</p>
<p>Apparently arrays are covered heavily on the Zend PHP Certification Exam so the next few posts will cover arrays.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/13/comparing-arrays-in-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Default Values for By-Reference Parameters</title>
		<link>http://zend-php-certification.com/2012/12/13/default-values-for-by-reference-parameters/</link>
		<comments>http://zend-php-certification.com/2012/12/13/default-values-for-by-reference-parameters/#comments</comments>
		<pubDate>Thu, 13 Dec 2012 01:30:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[by-reference default values]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[variable length arguments]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=23</guid>
		<description><![CDATA[Unlike PHP 4, PHP 5 allows default values to be specified for parameters even when they are declared as by-reference: &#160; function command_exists&#40;$command, &#38;$output = null&#41; &#123; &#160; &#160; &#160; &#160; $output = ‘whereis $cmd‘; &#160; &#160; &#160; &#160; if &#40;strpos&#40;$output, DIRECTORY_SEPARATOR&#41; !== false&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; return true; [...]]]></description>
				<content:encoded><![CDATA[<p>Unlike PHP 4, PHP 5 allows default values to be specified for parameters even when they are declared as by-reference:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> command_exists<span class="br0">&#40;</span><span class="re0">$command</span>, &amp;<span class="re0">$output</span> = <span class="kw2">null</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$output</span> = ‘whereis <span class="re0">$cmd</span>‘;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/strpos"><span class="kw3">strpos</span></a><span class="br0">&#40;</span><span class="re0">$output</span>, DIRECTORY_SEPARATOR<span class="br0">&#41;</span> !== <span class="kw2">false</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>In the example above, the $output parameter is completely optional—if a variable is not passed in, a new one will be created within the context of command_exists() and, of<br />
course, destroyed when the function returns.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/13/default-values-for-by-reference-parameters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function Name Case Sensitivity and Variable-Length Argument Lists</title>
		<link>http://zend-php-certification.com/2012/12/11/function-name-case-sensitivity-and-variable-length-argument-lists/</link>
		<comments>http://zend-php-certification.com/2012/12/11/function-name-case-sensitivity-and-variable-length-argument-lists/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 23:20:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[function name case sensitivity]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[variable length arguments]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=21</guid>
		<description><![CDATA[After spending years developing software, I&#8217;ve always assumed that most real programming languages are extremely case sensitive in almost every aspect. It turns out that PHP function names are not case-sensitive. I was extremely surprised to read this and I definitely don&#8217;t agree with it. Variables in PHP are case sensitive so it could be [...]]]></description>
				<content:encoded><![CDATA[<p>After spending years developing software, I&#8217;ve always assumed that most real programming languages are extremely case sensitive in almost every aspect. It turns out that PHP function names are not case-sensitive. I was extremely surprised to read this and I definitely don&#8217;t agree with it. Variables in PHP are case sensitive so it could be worse.</p>
<p>It was interesting to find out that PHP function parameters can be defined on the fly. PHP provides three built-in functions to handle variable-length argument lists: func_num_args(), func_get_arg() and func_get_args(). </p>
<p>Here’s an example of how they’re used:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> hello<span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><a href="http://www.php.net/func_num_args"><span class="kw3">func_num_args</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$arg</span> = <a href="http://www.php.net/func_get_arg"><span class="kw3">func_get_arg</span></a><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>; <span class="co1">// The first argument is at position 0</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;Hello $arg&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&quot;Hello World&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">hello<span class="br0">&#40;</span><span class="st0">&quot;Reader&quot;</span><span class="br0">&#41;</span>; <span class="co1">// Displays &quot;Hello Reader&quot;</span></div>
</li>
<li class="li1">
<div class="de1">hello<span class="br0">&#40;</span><span class="br0">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Displays &quot;Hello World&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>The variable-length arguments will actually be useful instead of something that I&#8217;m just learning to get designated as a Zend Certified Engineer.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/11/function-name-case-sensitivity-and-variable-length-argument-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backticks, EOL, and Break</title>
		<link>http://zend-php-certification.com/2012/12/11/backticks-eol-and-break/</link>
		<comments>http://zend-php-certification.com/2012/12/11/backticks-eol-and-break/#comments</comments>
		<pubDate>Tue, 11 Dec 2012 21:17:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[backticks]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[PHP_EOL]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=19</guid>
		<description><![CDATA[While studying up for the Zend PHP Certification exam I came across a few more elements that I&#8217;ve never used before. Firstly, there is a backtick operator. This makes it possible to execute a shell command and retrieve its output. For example,the following will cause the output of the UNIX ls command to be stored [...]]]></description>
				<content:encoded><![CDATA[<p>While studying up for the Zend PHP Certification exam I came across a few more elements that I&#8217;ve never used before.</p>
<p>Firstly, there is a backtick operator. This makes it possible to execute a shell command and retrieve<br />
its output. For example,the following will cause the output of the UNIX ls command to be stored inside $a:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = ‘ls -l‘;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>Secondly, PHP has an end of line constant. I&#8217;ve never seen PHP_EOL before but it seems to work similar to &#8220;\n&#8221;.<br />
I don&#8217;t think I will ever use this due to the length when compared with &#8220;\n&#8221;.</p>
<p>Finally, a bit about the break function. I had no idea that both the break and continue statements take a<br />
paramenter which can instruct them to break out of multiple loops. I felt a bit silly that I didn&#8217;t already know this.<br />
Here is a simple example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span> = <span class="nu0">0</span>; <span class="re0">$i</span> &lt; <span class="nu0">10</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$j</span> = <span class="nu0">0</span>; <span class="re0">$j</span> &lt; <span class="nu0">3</span>; <span class="re0">$j</span>++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="br0">&#40;</span><span class="re0">$j</span> + <span class="re0">$i</span><span class="br0">&#41;</span> % <span class="nu0">5</span> == <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span> <span class="nu0">2</span>; <span class="co1">// Exit from this loop and the next one.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>There seems to be a lot that I&#8217;m going to have to study up on before I can become a Zend Certified Engineer.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/11/backticks-eol-and-break/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP References</title>
		<link>http://zend-php-certification.com/2012/12/08/php-references/</link>
		<comments>http://zend-php-certification.com/2012/12/08/php-references/#comments</comments>
		<pubDate>Sat, 08 Dec 2012 01:53:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=15</guid>
		<description><![CDATA[References in PHP are a way to access the content in a variable by different names. They are not at all like pointers in C. For instance, you cannot perform pointer arithmetic using them and they are not actual memory addresses. I&#8217;ve found that references in PHP are fairly rare, but in the few cases [...]]]></description>
				<content:encoded><![CDATA[<p>References in PHP are a way to access the content in a variable by different names. They are not at all like pointers in C. For instance, you cannot perform pointer arithmetic using them and they are not actual memory addresses.</p>
<p>I&#8217;ve found that references in PHP are fairly rare, but in the few cases I&#8217;ve seen them in the wild, I&#8217;ve always assumed that they were used for their faster performance but it turns out that by-reference activity is often slower than its by-value counterpart, because PHP uses a clever “deferred-copy” mechanism that actually optimizes by-value assignments.</p>
<p>Here is a simple php reference example:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$a</span> = <span class="nu0">10</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = &amp;<span class="re0">$a</span>; <span class="co1">// by reference</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$b</span> = <span class="nu0">20</span>;</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$a</span>; <span class="co1">// Outputs 20</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>However PHP references are useful when used as a return value for a function. If they are used on something like<br />
a database resource then you probably don&#8217;t want to be returning a copy:</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> &amp;query<span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$result</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$result</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>References can also be useful as a function parameter to pass by reference instead of by copy. So any changes that are made to the parameter survive the function.</p>
<p>One thing to watch out for when using references in a foreach loop is to make sure that you unset the reference. Otherwise you may inadvertently overwrite the last entry in the array.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">foreach</span><span class="br0">&#40;</span><span class="re0">$data_array</span> <span class="kw1">as</span> &amp;<span class="re0">$value</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; do_something_with_value<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$value</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>I definitely expext at least a few questions to touch on references on the Zend PHP Certification Exam.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/08/php-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variable Variables and Variable Functions in PHP</title>
		<link>http://zend-php-certification.com/2012/12/07/variable-variables-and-variable-functions-in-php/</link>
		<comments>http://zend-php-certification.com/2012/12/07/variable-variables-and-variable-functions-in-php/#comments</comments>
		<pubDate>Fri, 07 Dec 2012 02:53:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Certification]]></category>
		<category><![CDATA[Exam]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Study]]></category>
		<category><![CDATA[Zend]]></category>
		<category><![CDATA[exam]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[php variable functions]]></category>
		<category><![CDATA[php variable variables]]></category>
		<category><![CDATA[print]]></category>
		<category><![CDATA[study]]></category>
		<category><![CDATA[zend]]></category>
		<category><![CDATA[zend certification exam]]></category>
		<category><![CDATA[Zend Certified Engineer]]></category>
		<category><![CDATA[Zend Engineer]]></category>
		<category><![CDATA[zend php]]></category>
		<category><![CDATA[zend php certification]]></category>

		<guid isPermaLink="false">http://zend-php-certification.com/?p=13</guid>
		<description><![CDATA[Variable Variables and Function Variables in PHP PHP variable variables are almost never used because they greatly obfuscate any application that you&#8217;re trying to write and can very easily inject a number of bugs into a script. That being said, this interesting little feature just may be on the Zend PHP Certification Exam. Variable variables [...]]]></description>
				<content:encoded><![CDATA[<p>Variable Variables and Function Variables in PHP</p>
<p>PHP variable variables are almost never used because they greatly obfuscate any application<br />
that you&#8217;re trying to write and can very easily inject a number of bugs into a script.<br />
That being said, this interesting little feature just may be on the Zend PHP Certification Exam. </p>
<p>Variable variables use a variable as the name of another variable.<br />
You may think that these are kind of like a pointer in other languages and I guess they are<br />
except you can&#8217;t do any of the fun pointer arithmetic. Here&#8217;s a simple example of using the<br />
value of another variable for a variable&#8217;s name.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$name</span> = ’foo’;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$$name</span> = ’bar’;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$foo</span>;</div>
</li>
<li class="li2">
<div class="de2"><span class="co1">// Displays ’bar’</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>This could also be used to have a number as a variable name (which normally isn&#8217;t allowed): </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$name</span> = ’<span class="nu0">123</span>’;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$$name</span> = ’<span class="nu0">456</span>’;</div>
</li>
<li class="li1">
<div class="de1"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> $<span class="br0">&#123;</span>’<span class="nu0">123</span>’<span class="br0">&#125;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>While on the topic of PHP pointer like stuff, it is also possible to use a variable as a function pointer<br />
like in the following example.</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> myFunc<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> ’myFunc!’;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="re0">$f</span> = ’myFunc’;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$f</span><span class="br0">&#40;</span><span class="br0">&#41;</span>; <span class="co1">// will call myFunc();</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>I don&#8217;t think I&#8217;ll be using any of these features in my applications any time soon but hopefully I<br />
won&#8217;t be clueless when taking the Zend PHP Certification Exam to become a Certified Zend Engineer.</p>
]]></content:encoded>
			<wfw:commentRss>http://zend-php-certification.com/2012/12/07/variable-variables-and-variable-functions-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
