<?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>PHP Reference Book Blog &#187; Clarifications</title>
	<atom:link href="http://www.phpreferencebook.com/category/clarifications/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpreferencebook.com</link>
	<description>PHP Reference: Beginner to Intermediate PHP5</description>
	<lastBuildDate>Sat, 03 Jul 2010 04:04:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Control Structures Without Curly Braces</title>
		<link>http://www.phpreferencebook.com/clarifications/control-structures-curly-braces/</link>
		<comments>http://www.phpreferencebook.com/clarifications/control-structures-curly-braces/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 17:00:53 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Clarifications]]></category>
		<category><![CDATA[control structures]]></category>
		<category><![CDATA[do-while]]></category>
		<category><![CDATA[else]]></category>
		<category><![CDATA[elseif]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[switch]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=44</guid>
		<description><![CDATA[In the book I cover the standard syntax methods for if, elseif, else, while, do-while, switch, for, and foreach. Here is the if statement syntax: if &#40;expr&#41; &#123; // If expr is TRUE,  do this, then exit the IF loop &#125;elseif &#40;expr2&#41; &#123; // If expr is FALSE, and expr2 is TRUE, do this, then [...]]]></description>
			<content:encoded><![CDATA[<p>In the book I cover the standard syntax methods for if, elseif, else, while, do-while, switch, for, and foreach. Here is the if statement syntax:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>expr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// If expr is TRUE,  do this, then exit the IF loop</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span>expr2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// If expr is FALSE, and expr2 is TRUE, do this, then exit the loop</span>
<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">// If all expr's are FALSE, do this, then exit</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>While accurate, there is a shorthand method that does not involve the curly bracket. If there is only a single evaluation, you can remove the curly braces completely. The following two examples are both completely valid syntax for control structures:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$a</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">echo</span> <span style="color: #000088;">$a</span><span style="color: #339933;">;</span> <span style="color: #000088;">$a</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now, I still recommend using curly brackets, if only for clarity and consistency (excluding them for the second line above would make your life much harder than necessary, but I thought a clarification was in order. For more information on Control Structions, check out chapter 3, pages 25-32 of the <a href="http://www.phpreferencebook.com/pdf/">free PHP book PDF</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/clarifications/control-structures-curly-braces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Language constructs vs functions in Control Structures</title>
		<link>http://www.phpreferencebook.com/clarifications/language-constructs-vs-functions-in-control-structures/</link>
		<comments>http://www.phpreferencebook.com/clarifications/language-constructs-vs-functions-in-control-structures/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 05:30:56 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Clarifications]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[include]]></category>
		<category><![CDATA[include_once]]></category>
		<category><![CDATA[language construct]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[require]]></category>
		<category><![CDATA[require_once]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=11</guid>
		<description><![CDATA[require(), require_once(), include(), include_once() (pgs. 31-32) Throughout the noted pages and scattered in a few other places, the above four are referred to as functions, when technically they are considered language constructs. While minor, it should still be clarified. All the functionality and examples are accurate, just some terminology clarifications.]]></description>
			<content:encoded><![CDATA[<h3>require(), require_once(), include(), include_once()</h3>
<h4>(pgs. 31-32)</h4>
<p>Throughout the noted pages and scattered in a few other places, the above four are referred to as functions, when technically they are considered language constructs. While minor, it should still be clarified. All the functionality and examples are accurate, just some terminology clarifications.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/clarifications/language-constructs-vs-functions-in-control-structures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mysql_real_escape_string() vs addslashes()</title>
		<link>http://www.phpreferencebook.com/clarifications/mysql_real_escape_string-vs-addslashes/</link>
		<comments>http://www.phpreferencebook.com/clarifications/mysql_real_escape_string-vs-addslashes/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 05:24:08 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Clarifications]]></category>
		<category><![CDATA[addslashes]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysql_real_escape_string]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=10</guid>
		<description><![CDATA[(pgs. 124-125) When describing the function mysql_real_escape_string(), the following note was included: Note: Performs the same functionality as addslashes(). While they are practically identical in their behavior, this is an oversimplification of the extra strength of mysql_real_escape_string(). At this point, I will pass on the following blog post that provides some extra insight into the [...]]]></description>
			<content:encoded><![CDATA[<h4>(pgs. 124-125)</h4>
<p>When describing the function <strong>mysql_real_escape_string()</strong>, the following note was included:</p>
<blockquote><p><em>Note: Performs the same functionality as <strong>addslashes()</strong>.</em></p></blockquote>
<p>While they are practically identical in their behavior, this is an oversimplification of the extra strength of <strong>mysql_real_escape_string()</strong>. At this point, I will pass on the following blog post that provides some extra insight into the comparison of the two variables:<a title="addslashes() Versus mysql_real_escape_string()" href="http://shiflett.org/blog/2006/jan/addslashes-versus-mysql-real-escape-string" target="_blank">addslashes() Versus mysql_real_escape_string()</a> by Chris Shiflett. I was not previously aware of this difference and security loophole.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/clarifications/mysql_real_escape_string-vs-addslashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>define() referenced in Global Variables</title>
		<link>http://www.phpreferencebook.com/clarifications/define-referenced-in-global-variables/</link>
		<comments>http://www.phpreferencebook.com/clarifications/define-referenced-in-global-variables/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 05:03:14 +0000</pubDate>
		<dc:creator>Mario Lurig</dc:creator>
				<category><![CDATA[Clarifications]]></category>
		<category><![CDATA[define]]></category>
		<category><![CDATA[global]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://www.phpreferencebook.com/?p=9</guid>
		<description><![CDATA[(pg. 33) The opening sentence for the Global Variables chapter reads as follows: While some global variables can be created through the use of define(), some are reserved because of a special function, giving access to different types of data. Technically, the define() function creates a constant that is available globally, as is described properly [...]]]></description>
			<content:encoded><![CDATA[<h3>(pg. 33)</h3>
<p>The opening sentence for the Global Variables chapter reads as follows:</p>
<blockquote><p>While some global variables can be created through the use of<br />
<strong>define()</strong>, some are reserved because of a special function, giving access to<br />
different types of data.</p></blockquote>
<p>Technically, the <strong>define()</strong> function creates a constant that is available globally, as is described properly as part of the function on page 11. Therefore, the sentence would be better phrased as follows:</p>
<blockquote><p>While some constants can be made available globally through the use of<br />
<strong>define()</strong>, some are reserved because of a special function, giving access to<br />
different types of data.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpreferencebook.com/clarifications/define-referenced-in-global-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
