<?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>Procedural programming languages &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/procedural-programming-languages/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>PHP Strings Don&#8217;t Need Quotes</title>
		<link>/2012/04/26/php-strings-dont-need-quotes/</link>
		<comments>/2012/04/26/php-strings-dont-need-quotes/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 13:52:53 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[PHP interpreter]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Programming language]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Social Issues]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[String]]></category>

		<guid isPermaLink="false">/?p=3017</guid>
		<description><![CDATA[I bet you didn&#8217;t know that PHP strings don&#8217;t need quotes! Indeed PHP developers work with strings with either single or double quotes, but actually in some cases you don&#8217;t need them. PHP by Book Here&#8217;s how PHP developer declare a string, which is something very common in any programming language. $my_var = 'hello world'; &#8230; <a href="/2012/04/26/php-strings-dont-need-quotes/" class="more-link">Continue reading <span class="screen-reader-text">PHP Strings Don&#8217;t Need Quotes</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/07/12/a-javascript-trick-you-should-know/" rel="bookmark" title="A JavaScript Trick You Should Know">A JavaScript Trick You Should Know </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2011/08/18/powerful-php-less-known-string-manipulation/" rel="bookmark" title="Powerful PHP: Less Known String Manipulation">Powerful PHP: Less Known String Manipulation </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>I bet you didn&#8217;t know that PHP strings don&#8217;t need quotes! Indeed PHP developers work with strings with either single or double quotes, but actually in some cases you don&#8217;t need them.</p>
<h2>PHP by Book</h2>
<p>Here&#8217;s how PHP developer declare a string, which is something very common in any programming language.</p>
<pre lang="PHP">
$my_var = 'hello world';
// or
$my_var = "hello world";
</pre>
<h2>PHP Tricks</h2>
<p>What if you do the following:</p>
<pre lang="PHP">
echo hello;
</pre>
<p>That appears to be correct &#8230; Well, it&#8217;s not absolutely correct. You&#8217;ll be &#8220;noticed&#8221;.</p>
<pre lang="PHP">
// Notice: Use of undefined constant hello
echo hello;
</pre>
<p>However if you disable error reporting, the code will be completely fine.</p>
<pre lang="PHP">
error_reporting(0);

// no problem now
echo hello;
</pre>
<h2>Variations</h2>
<p>What follows from the thing above is that you can use strings without quotes:</p>
<pre lang="PHP">
// hello
echo hello;

// hello world (concatenated)
echo hello . ' world';

// helloworld
echo hello . world;
</pre>
<p>However you can&#8217;t have spaces and most of the &#8220;special&#8221; symbols.</p>
<pre lang="PHP">
// syntax error
echo hello world;

// syntax error
echo hello!;
</pre>
<h2>Final Words</h2>
<p>Although you can do this in PHP, that is completely wrong. The code becomes more difficult to read and understand. In the second place you can miss a $ sign in front of a variable declaration and thus the PHP interpreter will assume this is a string. So disable error reporting isn&#8217;t so great sometimes.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/07/12/a-javascript-trick-you-should-know/" rel="bookmark" title="A JavaScript Trick You Should Know">A JavaScript Trick You Should Know </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2011/08/18/powerful-php-less-known-string-manipulation/" rel="bookmark" title="Powerful PHP: Less Known String Manipulation">Powerful PHP: Less Known String Manipulation </a></li>
<li><a href="/2010/06/10/json-and-zend-framework-zend_json/" rel="bookmark" title="JSON and Zend Framework? &#8211; Zend_Json">JSON and Zend Framework? &#8211; Zend_Json </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2012/04/26/php-strings-dont-need-quotes/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Object Cloning and Passing by Reference in PHP</title>
		<link>/2011/10/27/object-cloning-and-passing-by-reference-in-php/</link>
		<comments>/2011/10/27/object-cloning-and-passing-by-reference-in-php/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 14:25:17 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Clone]]></category>
		<category><![CDATA[Cloning]]></category>
		<category><![CDATA[Comparison of programming languages]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Java programming language]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>

		<guid isPermaLink="false">/?p=2408</guid>
		<description><![CDATA[In PHP everything&#8217;s a reference! I&#8217;ve heard it so many times in my practice. No, these words are too strong! Let&#8217;s see some examples. Passing Parameters by Reference Clearly when we pass parameters to a function it&#8217;s not by reference. How to check this? Well, like this. function f($param) { $param++; } $a = 5; &#8230; <a href="/2011/10/27/object-cloning-and-passing-by-reference-in-php/" class="more-link">Continue reading <span class="screen-reader-text">Object Cloning and Passing by Reference in PHP</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2012/08/17/its-not-true-that-php-arrays-are-copied-by-value/" rel="bookmark" title="It&#8217;s Not True that PHP Arrays are Copied by Value">It&#8217;s Not True that PHP Arrays are Copied by Value </a></li>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2011/10/20/some-notes-on-the-object-oriented-model-of-php/" rel="bookmark" title="Some Notes on the Object-oriented Model of PHP">Some Notes on the Object-oriented Model of PHP </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>In <a href="/category/php/" title="PHP at stoimen.com">PHP </a>everything&#8217;s a reference! I&#8217;ve heard it so many times in my practice. No, these words are too strong! Let&#8217;s see some examples.<br />
<figure id="attachment_2432" style="width: 480px" class="wp-caption alignnone"><a href="/wp-content/uploads/2011/10/ampersand.jpg"><img src="/wp-content/uploads/2011/10/ampersand.jpg" alt="Passing by reference in PHP can be tricky!" title="ampersand" width="480" height="480" class="size-full wp-image-2432" srcset="/wp-content/uploads/2011/10/ampersand.jpg 480w, /wp-content/uploads/2011/10/ampersand-150x150.jpg 150w, /wp-content/uploads/2011/10/ampersand-300x300.jpg 300w" sizes="(max-width: 480px) 100vw, 480px" /></a><figcaption class="wp-caption-text">Some developers think that everything&#039;s passed by reference in PHP.</figcaption></figure></p>
<h2>Passing Parameters by Reference</h2>
<p>Clearly when we pass parameters to a function it&#8217;s not by reference. How to check this? Well, like this.</p>
<pre lang="PHP">
function f($param)
{
	$param++;
}

$a = 5;
f($a);

echo $a;
</pre>
<p>Now the value of $a equals 5. If it were passed by reference, it would be 6. With a little change of the code we can get it.</p>
<pre lang="PHP">
function f(&$param)
{
	$param++;
}

$a = 5;
f($a);

echo $a;
</pre>
<p>Now the variable&#8217;s value is 6. </p>
<p>So far, so good. Now what about copying objects?<br />
<span id="more-2408"></span></p>
<h2>Objects: A Copy or a Cloning?</h2>
<p>We can check whether by assigning an object to a variable a reference or a copy of the object is passed.</p>
<pre lang="PHP">
class C
{
	public $myvar = 10;
}

$a = new C();
$b = $a;

$b->myvar = 20;

// 20, not 10
echo $a->myvar;
</pre>
<p>The last line outputs 20! This makes it clear. By assigning an object to a variable PHP pass its reference. To make a copy there&#8217;s another approach. We need to change $b = $a, to $b = clone $a;</p>
<pre lang="PHP" escaped="true">
class C
{
	public $myvar = 10;
}

$a = new C();
$b = clone $a;

$b->myvar = 20;

// 10
echo $a->myvar;
</pre>
<h2>Arrays by Reference</h2>
<p>What about arrays? What if I assign an array to a variable?</p>
<pre lang="PHP">
$a = array(20);

$b = $a;
$b[0] = 30;

var_dump($a);
</pre>
<p>What do you think is the value of $a[0]? Well, the answer is: 20! So $b is a copy of the array &#8220;a&#8221;. Instead you should assign explicitly its reference to make &#8220;b&#8221; point to &#8220;a&#8221;.</p>
<pre lang="PHP">
$a = array(20);

$b = &$a;
$b[0] = 30;

var_dump($a);
</pre>
<p>Now $a[0] equals 30!</p>
<p>I think this could be useful!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2012/08/17/its-not-true-that-php-arrays-are-copied-by-value/" rel="bookmark" title="It&#8217;s Not True that PHP Arrays are Copied by Value">It&#8217;s Not True that PHP Arrays are Copied by Value </a></li>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2011/10/20/some-notes-on-the-object-oriented-model-of-php/" rel="bookmark" title="Some Notes on the Object-oriented Model of PHP">Some Notes on the Object-oriented Model of PHP </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/10/27/object-cloning-and-passing-by-reference-in-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Does JavaScript undefined Equals undefined?</title>
		<link>/2011/10/21/does-javascript-undefined-equals-undefined/</link>
		<comments>/2011/10/21/does-javascript-undefined-equals-undefined/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 11:36:01 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[ecmascript]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[typeof]]></category>
		<category><![CDATA[undefined]]></category>

		<guid isPermaLink="false">/?p=2416</guid>
		<description><![CDATA[Weird JS As you know sometimes JavaScript can be weird. Let&#8217;s see the following example and let&#8217;s try to answer the question: does &#8220;undefined&#8221; equals &#8220;undefined&#8221;. What do I mean? First take a look at the following code. var a; var b = undefined; // alerts "false" alert(b == a); Both a and b are &#8230; <a href="/2011/10/21/does-javascript-undefined-equals-undefined/" class="more-link">Continue reading <span class="screen-reader-text">Does JavaScript undefined Equals undefined?</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/" rel="bookmark" title="OOP JavaScript: Accessing Public Methods in Private Methods">OOP JavaScript: Accessing Public Methods in Private Methods </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2011/05/30/object-oriented-javascript-inheritance/" rel="bookmark" title="Object Oriented JavaScript: Inheritance">Object Oriented JavaScript: Inheritance </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Weird JS</h2>
<figure id="attachment_2419" style="width: 480px" class="wp-caption alignnone"><a href="/wp-content/uploads/2011/10/question.mark_.jpg"><img src="/wp-content/uploads/2011/10/question.mark_.jpg" alt="Does &quot;undefined&quot; equals &quot;undefined&quot;?" title="question.mark" width="480" height="624" class="size-full wp-image-2419" srcset="/wp-content/uploads/2011/10/question.mark_.jpg 480w, /wp-content/uploads/2011/10/question.mark_-230x300.jpg 230w" sizes="(max-width: 480px) 100vw, 480px" /></a><figcaption class="wp-caption-text">Does JavaScript &quot;undefined&quot; equals &quot;undefined&quot;?</figcaption></figure>
<p>As you know sometimes JavaScript can be weird. Let&#8217;s see the following example and let&#8217;s try to answer the question: does &#8220;undefined&#8221; equals &#8220;undefined&#8221;. What do I mean?</p>
<p>First take a look at the following code.</p>
<pre lang="javascript">
var a;
var b = undefined;

// alerts "false"
alert(b == a);
</pre>
<p>Both <strong>a</strong> and <strong>b</strong> are <strong>undefined</strong>, but they are <strong>NOT</strong> equal. Now let&#8217;s see where it can become a problem.</p>
<p>We have an object with one member variable that is not defined.</p>
<pre lang="javascript">
var f1 = function()
{
	this.myvar;
};

var obj1 = new f1();
</pre>
<p>Now you&#8217;d like to know whether the object &#8220;b&#8221; has the property &#8220;myvar&#8221;. There are lots of examples online, but what&#8217;s the right way?<br />
<span id="more-2416"></span></p>
<h2>Wrong</h2>
<p>Appearantly the value of b.myvar should be undefined.</p>
<pre lang="javascript">
alert(obj1.myvar); // undefined
</pre>
<p>But that doesn&#8217;t mean that it is the same value if the object was declared this way:</p>
<pre lang="javascript">
var f2 = function()
{
	this.myvar = undefined;
};

var obj2 = new f2();
</pre>
<p>This is a completely different thing. Why? In the first case if we try to check whether the property myvar belongs to obj1 we can go wrong with:</p>
<pre lang="javascript">
if (obj1.myvar) // false
</pre>
<p>This is false simply because obj1.myvar is undefined</p>
<pre lang="javascript">
if (obj2.myvar) // false
</pre>
<p>Again is false, because obj2.myvar is undefined.</p>
<p>The same thing happen when using the other &#8220;famous&#8221; approach.</p>
<pre lang="javascript">
if (typeof obj1['myvar'] != 'undefined') // false
if (typeof obj2['myvar'] != 'undefined') // false
</pre>
<p>Clearly this is not the right answer, becase even it is undefined <strong>myvar </strong>belongs to <strong>obj2</strong>!</p>
<h2>Right</h2>
<p>Now let&#8217;s try with <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/hasOwnProperty" title="hasOwnProperty on MDN" target="_blank">hasOwnProperty</a> supported by almost every modern browser.</p>
<pre lang="javascript">
if (obj1.hasOwnProperty('myvar')); // false
if (obj2.hasOwnProperty('myvar')); // true
</pre>
<p>Here you can see that when the member variable is explicitly defined as &#8220;undefined&#8221; the object &#8220;has the property&#8221; and hasOwnProperty returns true. Yet again, &#8220;undefined&#8221; does not always equal to &#8220;undefined&#8221;.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/02/12/how-to-detect-a-variable-existence-in-javascript/" rel="bookmark" title="How to detect a variable existence in JavaScript?">How to detect a variable existence in JavaScript? </a></li>
<li><a href="/2011/07/28/oop-javascript-accessing-public-methods-in-private-methods/" rel="bookmark" title="OOP JavaScript: Accessing Public Methods in Private Methods">OOP JavaScript: Accessing Public Methods in Private Methods </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2011/05/30/object-oriented-javascript-inheritance/" rel="bookmark" title="Object Oriented JavaScript: Inheritance">Object Oriented JavaScript: Inheritance </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2011/10/21/does-javascript-undefined-equals-undefined/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>HTTP POST with PHP without cURL</title>
		<link>/2010/09/08/http-post-with-php-without-curl/</link>
		<comments>/2010/09/08/http-post-with-php-without-curl/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 21:47:27 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Form]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Truth]]></category>

		<guid isPermaLink="false">/?p=1960</guid>
		<description><![CDATA[Awesome PHP It&#8217;s strange how powerful PHP can be. There&#8217;s a legend that cURL is the only way to perform a HTTP POST with PHP, but that isn&#8217;t the truth. An extremely useful script is by using stream_context_create: $optional_headers = null; $params = array('http' => array( 'method' => 'POST', 'content' => http_build_query(array('name' => 'my-name')))); if &#8230; <a href="/2010/09/08/http-post-with-php-without-curl/" class="more-link">Continue reading <span class="screen-reader-text">HTTP POST with PHP without cURL</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/" rel="bookmark" title="PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings">PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Awesome PHP</h2>
<p><a href="/wp-content/uploads/2010/09/idea.jpeg"><img src="/wp-content/uploads/2010/09/idea.jpeg" alt="a great php idea!" title="idea" width="430" height="286" class="aligncenter size-full wp-image-1975" srcset="/wp-content/uploads/2010/09/idea.jpeg 430w, /wp-content/uploads/2010/09/idea-300x199.jpg 300w" sizes="(max-width: 430px) 100vw, 430px" /></a><br />
It&#8217;s strange how powerful PHP can be. There&#8217;s a legend that cURL is the only way to perform a HTTP POST with PHP, but that isn&#8217;t the truth. An extremely useful script is by using stream_context_create:</p>
<pre lang="php">
$optional_headers = null;
$params = array('http' => array(
                'method' => 'POST',
                'content' => http_build_query(array('name' => 'my-name'))));

if ($optional_headers !== null) {
    $params['http']['header'] = $optional_headers;
}

$ctx = stream_context_create($params);
$fp = @fopen('http://example.com/post.php', 'rb', false, $ctx);
</pre>
<p>Well this is only a snippet. You can change a lot this code and perform any request, but here&#8217;s a small start up. However note that this will do the same as while posting to example.com/post.php via web form!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
<li><a href="/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/" rel="bookmark" title="PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings">PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/09/08/http-post-with-php-without-curl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript</title>
		<link>/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/</link>
		<comments>/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 07:13:01 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[algorithms]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[Negation]]></category>
		<category><![CDATA[Null]]></category>
		<category><![CDATA[one sorting algorithm]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Quicksort]]></category>
		<category><![CDATA[Scripting languages]]></category>

		<guid isPermaLink="false">/?p=1602</guid>
		<description><![CDATA[Here&#8217;s some Friday fun. Let me show you one sorting algorithm, perhaps the most known of all them &#8211; the quick sort, implemented both on PHP and JavaScript. Although the code look similar between both languages, there are few differences, that show the importance of the syntax knowledge! 1. PHP<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/25/friday-algorithms-sorting-a-set-of-integers-far-quicker-than-quicksort/" rel="bookmark" title="Friday Algorithms: Sorting a Set of Integers &#8211; Far Quicker than Quicksort!">Friday Algorithms: Sorting a Set of Integers &#8211; Far Quicker than Quicksort! </a></li>
<li><a href="/2010/06/18/friday-algorithms-iterative-quicksort/" rel="bookmark" title="Friday Algorithms: Iterative Quicksort">Friday Algorithms: Iterative Quicksort </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/07/09/friday-algorithms-javascript-bubble-sort/" rel="bookmark" title="Friday Algorithms: JavaScript Bubble Sort">Friday Algorithms: JavaScript Bubble Sort </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s some Friday fun. Let me show you one sorting algorithm, perhaps the most known of all them &#8211; the quick sort, implemented both on PHP and JavaScript. Although the code look similar between both languages, there are few differences, that show the importance of the syntax knowledge!</p>
<h3>1. PHP</h3>
<pre lang="php">
<?php

    $unsorted = array(2,4,5,63,4,5,63,2,4,43);

    function quicksort($array)
    {
        if (count($array) == 0)
            return array();

        $pivot = $array[0];
        $left = $right = array();

        for ($i = 1; $i < count($array); $i++) {
            if ($array[$i] < $pivot)
                $left[] = $array[$i];
            else
                $right[] = $array[$i];
        }

        return array_merge(quicksort($left), array($pivot), quicksort($right));
    }

    $sorted = quicksort($unsorted);

    print_r($sorted);
</pre>
<h3>2. JavaScript</h3>
<pre lang="javascript">
var a = [2,4,5,63,4,5,63,2,4,43];

function quicksort(arr)
{
    if (arr.length == 0)
        return [];

    var left = new Array();
    var right = new Array();
    var pivot = arr[0];

    for (var i = 1; i < arr.length; i++) {
        if (arr[i] < pivot) {
           left.push(arr[i]);
        } else {
           right.push(arr[i]);
        }
    }

    return quicksort(left).concat(pivot, quicksort(right));
}

console.log(quicksort(a));
</pre>
<p>Note that the first conditional statement is quite important! While in PHP the count function will return 0 either on a NULL value or an empty array and you can substitute it with something like count($array) &lt; 2</p>
<pre lang="php">
if (count($array) < 2)
	return $array;
</pre>
<p>in JavaScript you cannot use that because of the presence of the 'undefined' value when an "empty" array is passed as an argument. Thus you've the conditional above:</p>
<pre lang="javascript">
// this will result with an error
if (arr.length < 2)
        return arr;
</pre>
<h2>Coming Up Next ...</h2>
<p>An iterative version of the algorithm next Friday!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/25/friday-algorithms-sorting-a-set-of-integers-far-quicker-than-quicksort/" rel="bookmark" title="Friday Algorithms: Sorting a Set of Integers &#8211; Far Quicker than Quicksort!">Friday Algorithms: Sorting a Set of Integers &#8211; Far Quicker than Quicksort! </a></li>
<li><a href="/2010/06/18/friday-algorithms-iterative-quicksort/" rel="bookmark" title="Friday Algorithms: Iterative Quicksort">Friday Algorithms: Iterative Quicksort </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/07/09/friday-algorithms-javascript-bubble-sort/" rel="bookmark" title="Friday Algorithms: JavaScript Bubble Sort">Friday Algorithms: JavaScript Bubble Sort </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>JSON and Zend Framework? &#8211; Zend_Json</title>
		<link>/2010/06/10/json-and-zend-framework-zend_json/</link>
		<comments>/2010/06/10/json-and-zend-framework-zend_json/#respond</comments>
		<pubDate>Thu, 10 Jun 2010 14:08:59 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[Whitespace]]></category>

		<guid isPermaLink="false">/?p=1603</guid>
		<description><![CDATA[That&#8217;s really a good Zend Framework&#8217;s class that help you do the encode/decode job very easily. First of all it escapes everything for you and second it prints a correct/valid code. Note that sometimes if you have a trailing whitespace after the closing PHP tag &#8211; ?&#62; that will result in an error. Here&#8217;s some &#8230; <a href="/2010/06/10/json-and-zend-framework-zend_json/" class="more-link">Continue reading <span class="screen-reader-text">JSON and Zend Framework? &#8211; Zend_Json</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/08/13/returning-json-in-a-zend-controllers-action/" rel="bookmark" title="Returning JSON in a Zend Controller&#8217;s Action">Returning JSON in a Zend Controller&#8217;s Action </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
<li><a href="/2010/04/09/secure-forms-with-zend-framework/" rel="bookmark" title="Secure Forms with Zend Framework">Secure Forms with Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>That&#8217;s really a good Zend Framework&#8217;s class that help you do the encode/decode job very easily. First of all it escapes everything for you and second it prints a correct/valid code. Note that sometimes if you have a trailing whitespace after the closing PHP tag &#8211; ?&gt; that will result in an error.</p>
<p>Here&#8217;s some code:</p>
<pre lang="php">
public function jsonAction()
{
	$data = array(3,4,'test', 'my-name' => 3,4);

	echo Zend_Json::encode($data);

	$this->_helper->viewRenderer->setNoRender(true);
	$this->view->layout()->disableLayout();
}
</pre>
<p>and the result is:</p>
<pre lang="html4strict">
{"0":3,"1":4,"2":"test","my-name":3,"3":4}
</pre>
<p>Note that all integers are printed without double quotes &#8211; which saves some space!</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/08/13/returning-json-in-a-zend-controllers-action/" rel="bookmark" title="Returning JSON in a Zend Controller&#8217;s Action">Returning JSON in a Zend Controller&#8217;s Action </a></li>
<li><a href="/2010/07/07/default-error-handling-in-zend-framework/" rel="bookmark" title="Default Error Handling in Zend Framework">Default Error Handling in Zend Framework </a></li>
<li><a href="/2010/07/06/zend-framework-simple-acl-front-controller-plugin/" rel="bookmark" title="Zend Framework: Simple Acl Front Controller Plugin">Zend Framework: Simple Acl Front Controller Plugin </a></li>
<li><a href="/2010/04/09/secure-forms-with-zend-framework/" rel="bookmark" title="Secure Forms with Zend Framework">Secure Forms with Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/06/10/json-and-zend-framework-zend_json/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Objects Coding Style</title>
		<link>/2010/05/24/javascript-objects-coding-style/</link>
		<comments>/2010/05/24/javascript-objects-coding-style/#comments</comments>
		<pubDate>Mon, 24 May 2010 07:48:50 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Associative array]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computer science]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[JavaScript programming language]]></category>
		<category><![CDATA[JavaScript syntax]]></category>
		<category><![CDATA[Negation]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>

		<guid isPermaLink="false">/?p=1557</guid>
		<description><![CDATA[JavaScript vs. PHP Continuing from my post about PHP arrays coding style and following the comments of that post, I&#8217;d like to write a bit about JavaScript objects&#8217; coding style. You perhaps know that the term object is quite undefined or under estimated in the JavaScript world, but I&#8217;d speak about the key/value pairs in &#8230; <a href="/2010/05/24/javascript-objects-coding-style/" class="more-link">Continue reading <span class="screen-reader-text">JavaScript Objects Coding Style</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/12/03/javascript-objects-coding-style-reviewed/" rel="bookmark" title="JavaScript Objects Coding Style Reviewed">JavaScript Objects Coding Style Reviewed </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/08/11/quick-look-at-javascript-objects/" rel="bookmark" title="Quick Look at JavaScript Objects">Quick Look at JavaScript Objects </a></li>
<li><a href="/2010/02/24/storing-javascript-objects-in-html5-localstorage/" rel="bookmark" title="Storing JavaScript objects in html5 localStorage">Storing JavaScript objects in html5 localStorage </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>JavaScript vs. PHP</h2>
<p>Continuing from my <a title="PHP Arrays Coding Style" href="/2010/05/19/php-associative-arrays-coding-style/" target="_self">post</a> about PHP arrays coding style and following the comments of that post, I&#8217;d like to write a bit about JavaScript objects&#8217; coding style.</p>
<p>You perhaps know that the term object is quite undefined or under estimated in the JavaScript world, but I&#8217;d speak about the key/value pairs in JS commonly formatted like that:</p>
<pre lang="javascript">
var obj = { key : 'value' }
</pre>
<p>Here you can add more and more key/value pairs, but what&#8217;s different from the PHP associative arrays and what&#8217;s the same and should be cosidered.</p>
<h2>The Same as PHP?</h2>
<p>I wrote about the alignment in PHP and hashes. Than I showed how I align them:</p>
<pre lang="php">
$arr = array(
   'short'   => 'val',
   'longkey' => 'val'
);
</pre>
<p>In JavaScript you should use the same technique of alignment:</p>
<pre lang="php">
var obj = {
   'short'   : 'val',
   'longkey' : 'val'
};
</pre>
<h2>Some Differences</h2>
<p>Yes, there are more differences, which is normal. First of all you don&#8217;t have the =&gt; notation in JavaScript and a : is used. Second and most important you cannot add a trailing comma after the last key/value pair. Note that in PHP that&#8217;s fine!</p>
<pre lang="javascript">
// that will throw an error in MSIE
var obj = {
   'short'   : 'val',
   'longkey' : 'val',
};
</pre>
<p>while this is OK in PHP and it&#8217;s encouraged:</p>
<pre lang="php">
$arr = array(
   'short'   => 'val',
   'longkey' => 'val',
);
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/12/03/javascript-objects-coding-style-reviewed/" rel="bookmark" title="JavaScript Objects Coding Style Reviewed">JavaScript Objects Coding Style Reviewed </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
<li><a href="/2010/08/11/quick-look-at-javascript-objects/" rel="bookmark" title="Quick Look at JavaScript Objects">Quick Look at JavaScript Objects </a></li>
<li><a href="/2010/02/24/storing-javascript-objects-in-html5-localstorage/" rel="bookmark" title="Storing JavaScript objects in html5 localStorage">Storing JavaScript objects in html5 localStorage </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/05/24/javascript-objects-coding-style/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Associative Arrays Coding Style</title>
		<link>/2010/05/19/php-associative-arrays-coding-style/</link>
		<comments>/2010/05/19/php-associative-arrays-coding-style/#comments</comments>
		<pubDate>Wed, 19 May 2010 14:14:03 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Human Interest]]></category>
		<category><![CDATA[Initialisms]]></category>
		<category><![CDATA[PHAML]]></category>
		<category><![CDATA[PHP programmer]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">/?p=1532</guid>
		<description><![CDATA[No PHP programmer writes code without arrays. Sound strange, but as many programmers there are, as many ways to format the array notation there are. My advice is to rely on a defined standard. I personally use the Zend Framework&#8217;s coding style. So how to format the code? The first way is on the same &#8230; <a href="/2010/05/19/php-associative-arrays-coding-style/" class="more-link">Continue reading <span class="screen-reader-text">PHP Associative Arrays Coding Style</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/12/03/javascript-objects-coding-style-reviewed/" rel="bookmark" title="JavaScript Objects Coding Style Reviewed">JavaScript Objects Coding Style Reviewed </a></li>
<li><a href="/2010/05/25/php-coding-style-large-if-statements/" rel="bookmark" title="PHP Coding Style: Large IF Statements">PHP Coding Style: Large IF Statements </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/05/26/php-conditionals-coding-style/" rel="bookmark" title="PHP: Conditionals Coding Style">PHP: Conditionals Coding Style </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>No PHP programmer writes code without arrays. Sound strange, but as many programmers there are, as many ways to format the array notation there are.</p>
<p>My advice is to rely on a defined standard. I personally use the Zend Framework&#8217;s coding style.</p>
<p>So how to format the code? The first way is on the same line:</p>
<pre lang="php" escaped="true">$myArray = array('key1' =&gt; 'value1',
		 'key2' =&gt; 'value2');
</pre>
<p>And the other, perhaps more clear way is to place the associative pairs on a new line:</p>
<pre lang="php" escaped="true">$myArray = array(
	'key1' =&gt; 'value1',
	'key2' =&gt; 'value2',
);
</pre>
<p>Note that in the second example there&#8217;s a comma after the second pair. This is correct PHP syntax and is strongly encouraged!</p>
<p>It&#8217;s up to you which way to take. However it mainly depends on the case, but please use standards.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/12/03/javascript-objects-coding-style-reviewed/" rel="bookmark" title="JavaScript Objects Coding Style Reviewed">JavaScript Objects Coding Style Reviewed </a></li>
<li><a href="/2010/05/25/php-coding-style-large-if-statements/" rel="bookmark" title="PHP Coding Style: Large IF Statements">PHP Coding Style: Large IF Statements </a></li>
<li><a href="/2010/05/24/javascript-objects-coding-style/" rel="bookmark" title="JavaScript Objects Coding Style">JavaScript Objects Coding Style </a></li>
<li><a href="/2010/05/26/php-conditionals-coding-style/" rel="bookmark" title="PHP: Conditionals Coding Style">PHP: Conditionals Coding Style </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/05/19/php-associative-arrays-coding-style/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings</title>
		<link>/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/</link>
		<comments>/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/#respond</comments>
		<pubDate>Mon, 17 May 2010 16:54:23 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Addition]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[elegant solution]]></category>
		<category><![CDATA[Mathematics]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>

		<guid isPermaLink="false">/?p=1525</guid>
		<description><![CDATA[What&#8217;s the problem? If you code PHP from couple of hours you are probably familiar with the following problem: The first and most common solution is just by adding the isset() statement and the code will look like that: However do you know there&#8217;s is another simple and elegant solution? Simply add the @ sign &#8230; <a href="/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/" class="more-link">Continue reading <span class="screen-reader-text">PHP: The Array Element Doesn&#8217;t Exist &#8211; Suppress the Warnings</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2009/07/08/jquery-check-for-element-visibility/" rel="bookmark" title="jQuery check for element visibility">jQuery check for element visibility </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>What&#8217;s the problem?</p>
<p>If you code PHP from couple of hours you are probably familiar with the following problem:</p>
<pre lang="php" line="1">
<?php

	error_reporting(E_ALL);
	
	$arr = array();
	
	echo $arr[3];

?>
</pre>
<p>The first and most common solution is just by adding the isset() statement and the code will look like that:</p>
<pre lang="php" line="1">
<?php

	error_reporting(E_ALL);
	
	$arr = array();
	
        if (isset($arr[3]))
	        echo $arr[3];

?>
</pre>
<p>However do you know there&#8217;s is another simple and elegant solution? Simply add the @ sign to suppress the element existence</p>
<pre lang="php" line="1">
<?php

	error_reporting(E_ALL);
	
	$arr = array();
	
	echo @$arr[3];

?>
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2009/07/08/jquery-check-for-element-visibility/" rel="bookmark" title="jQuery check for element visibility">jQuery check for element visibility </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
<li><a href="/2010/06/11/friday-algorithms-quicksort-difference-between-php-and-javascript/" rel="bookmark" title="Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript">Friday Algorithms: Quicksort &#8211; Difference Between PHP and JavaScript </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/05/17/php-the-array-element-doesnt-exist-suppress-the-warnings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Tag Semantics. STRONG vs. B!</title>
		<link>/2010/03/11/html-tag-semantics-strong-vs-b/</link>
		<comments>/2010/03/11/html-tag-semantics-strong-vs-b/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 12:09:17 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[Label]]></category>
		<category><![CDATA[Markup languages]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Singular they]]></category>
		<category><![CDATA[Span and div]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[web project]]></category>

		<guid isPermaLink="false">/?p=1246</guid>
		<description><![CDATA[Do You Use LABEL? Have you ever mentioned the existence of the LABEL tag? Have you ever used it? I guess the majority of us don&#8217;t. Let&#8217;s take a look of the following chunk of code: &#60;label&#62;username:&#60;/label&#62; &#60;input type="text" name="username" /&#62; It looks familiar to every web developer, but the most common usage in web &#8230; <a href="/2010/03/11/html-tag-semantics-strong-vs-b/" class="more-link">Continue reading <span class="screen-reader-text">HTML Tag Semantics. STRONG vs. B!</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
<li><a href="/2010/03/02/fast-way-to-manage-the-arabic-version-of-a-web-form/" rel="bookmark" title="Fast way to manage the Arabic version of a web form">Fast way to manage the Arabic version of a web form </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Do You Use LABEL?</h2>
<p>Have you ever mentioned the existence of the <strong>LABEL</strong> tag? Have you ever used it? I guess the majority of us don&#8217;t. Let&#8217;s take a look of the following chunk of code:</p>
<pre lang="html4strict" escaped="true">&lt;label&gt;username:&lt;/label&gt; &lt;input type="text" name="username" /&gt;</pre>
<p>It looks familiar to every web developer, but the most common usage in web forms is:</p>
<pre lang="html4strict" escaped="true">&lt;div&gt;username:&lt;/div&gt;</pre>
<p>or</p>
<pre lang="html4strict" escaped="true">&lt;span&gt;username:&lt;/span&gt;</pre>
<h2>How Looks a LABEL Tag?</h2>
<p>In fact if you use LABEL for the form instead of DIV or SPAN you&#8217;ll get the exactly same result as layout, beside that most common usage is a DIV or SPAN in place of the forgotten LABEL?! Why is that?</p>
<blockquote style="text-align: center;"><p><a href="/wp-content/uploads/2010/03/label.vs_.span_.png"><img class="size-full wp-image-1258" title="label.vs.span" src="/wp-content/uploads/2010/03/label.vs_.span_.png" alt="html tags. Label vs Span" width="288" height="120" /></a><br />
Can you see the difference between LABEL and SPAN?</p></blockquote>
<p>For me the usage of DIV has become critically enormous. It may sound strange that there is a debate about the usage of one or another HTML tag, but don&#8217;t you think every little text label in a web project is surrounded by a DIV. Actually that makes clear that if you&#8217;d like to be semantically correct, than you should use LABEL.</p>
<p>The funny thing is that almost every project is loading its labels in a PHP array or object or whatever and there they are called &#8220;Labels&#8221;, but when it comes to HTML they are put into a DIVs.</p>
<h2>Why Semantics Matters?</h2>
<p>In fact this is important because this is really good for web robots. If this is not important for the human eye it is for a machine &#8220;eye&#8221;. That&#8217;s why there are two tags for bold text.</p>
<h2>STRONG vs. B</h2>
<p>You can see that most of the browsers display both tags exactly the same by default.</p>
<blockquote style="text-align:center"><p><a href="/wp-content/uploads/2010/03/bold.vs_.strong.png"><img class="aligncenter size-full wp-image-1265" title="bold.vs.strong" src="/wp-content/uploads/2010/03/bold.vs_.strong.png" alt="Bold vs Strong HTML tags" width="177" height="39" /></a></p></blockquote>
<p>Why&#8217;s that? Because STRONG is semantically more important than &lt;B&gt;.</p>
<p>So if you want to make a text simply looking bold, wrap it in &lt;B&gt;, but if you want to make it important both for the human eye and for the machines, than use STRONG.</p>
<p><em><strong>Source:</strong> complete <a title="HTML tag semantics demo" href="http://www.stoimen.com/projects/html.tag.semantics/" target="_blank">demo</a>.</em></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/09/24/2xjquery-select-a-selector/" rel="bookmark" title="2xjQuery: Select a Selector">2xjQuery: Select a Selector </a></li>
<li><a href="/2010/01/12/faster-html-why-not/" rel="bookmark" title="Faster HTML! Why not?">Faster HTML! Why not? </a></li>
<li><a href="/2010/03/02/fast-way-to-manage-the-arabic-version-of-a-web-form/" rel="bookmark" title="Fast way to manage the Arabic version of a web form">Fast way to manage the Arabic version of a web form </a></li>
<li><a href="/2010/03/10/php-if-else-endif-statements/" rel="bookmark" title="PHP if-else-endif Statements">PHP if-else-endif Statements </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/11/html-tag-semantics-strong-vs-b/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
