<?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>axing's blog &#187; Programming</title>
	<atom:link href="http://xing.web.id/blog/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://xing.web.id/blog</link>
	<description>Renew, reload, re-新の空</description>
	<lastBuildDate>Wed, 24 Jun 2009 13:14:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Another way of joining table without JOIN syntax in SQL</title>
		<link>http://xing.web.id/blog/2009/04/another-way-of-joining-table-without-join-syntax-in-sql/</link>
		<comments>http://xing.web.id/blog/2009/04/another-way-of-joining-table-without-join-syntax-in-sql/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 04:54:43 +0000</pubDate>
		<dc:creator>axing</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://xing.web.id/blog/?p=116</guid>
		<description><![CDATA[We often use JOIN syntax for joining 2 or more tables in SQL. Such as INNER JOIN, OUTER JOIN, etc. But here I found another way of joining table that much like INNER JOIN, that is by tricking WHERE syntax.
Below is the example of INNER JOIN between table Customer and Member:

SELECT customer.name, member.name
FROM customer INNER [...]]]></description>
			<content:encoded><![CDATA[<p>We often use JOIN syntax for joining 2 or more tables in SQL. Such as INNER JOIN, OUTER JOIN, etc. But here I found another way of joining table that much like INNER JOIN, that is by tricking WHERE syntax.</p>
<p>Below is the example of INNER JOIN between table Customer and Member:</p>
<div class="code-snippet">
<pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> customer.name, member.name</pre>
<pre class="sql"><span style="color: #993333; font-weight: bold;">FROM</span> customer <span style="color: #993333; font-weight: bold;">INNER</span> <span style="color: #993333; font-weight: bold;">JOIN</span> member</pre>
<pre class="sql">     <span style="color: #993333; font-weight: bold;">ON</span> customer.member_id = member.id</pre>
</div>
<p>Here is the magic of using WHERE syntax:</p>
<div class="code-snippet">
<pre class="sql"><span style="color: #993333; font-weight: bold;">SELECT</span> customer.name, member.name</pre>
<pre class="sql"><span style="color: #993333; font-weight: bold;">FROM</span> customer, member</pre>
<pre class="sql"><span style="color: #993333; font-weight: bold;">WHERE</span> customer.member_id = member.id</pre>
</div>
<p>Though the syntax doesn't look shorter enough, but it will be very handy for some SQL statement that joins a lot of tables.</p>
<p>This trick works fine with <a href="http://www.mysql.com/">MySQL</a> and <a href="http://hsqldb.org/">HSQLDB</a>. I haven't tried on another engine yet.</p>
<p>Tell me if i made a mistake. <img src='http://xing.web.id/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  thanks</p>
]]></content:encoded>
			<wfw:commentRss>http://xing.web.id/blog/2009/04/another-way-of-joining-table-without-join-syntax-in-sql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Latest jQuery v1.3.2&#8217;s bug on WebKit</title>
		<link>http://xing.web.id/blog/2009/02/latest-jquery-v132s-bug-on-webkit/</link>
		<comments>http://xing.web.id/blog/2009/02/latest-jquery-v132s-bug-on-webkit/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 10:06:18 +0000</pubDate>
		<dc:creator>axing</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Bugs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slickspeed]]></category>
		<category><![CDATA[WebKit]]></category>

		<guid isPermaLink="false">http://xing.web.id/blog/?p=97</guid>
		<description><![CDATA[I found a bug (may be a browser bug) which is happen on my favorite framework, the latest version of jQuery (v1.3.2) on WebKit browser when I was trying slickspeed with some popular JavaScript Frameworks.
Here the screenshots:
Safari 3.1.2

Chrome 1.0.154.48
 
No problem found in Safari 3.1.2 Nightly, Firefox 3.0.6, Opera 9.63 and IE7.
Test the slickspeed here: http://xing.web.id/slickspeed/
Selectors I [...]]]></description>
			<content:encoded><![CDATA[<p>I found a bug (may be a browser bug) which is happen on my favorite framework, the latest version of <a title="jQuery" href="http://jquery.com" target="_blank">jQuery</a> (<a title="v1.3.2" href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.2.min.js" target="_blank">v1.3.2</a>) on WebKit browser when I was trying <a title="slickspeed" href="http://xing.web.id/slickspeed/" target="_blank">slickspeed</a> with some popular JavaScript Frameworks.</p>
<p>Here the screenshots:</p>
<p><a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-safari.jpg" target="_blank">Safari 3.1.2</a><br />
<a href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-safari.jpg" target="_blank"><img class="alignnone size-medium wp-image-102" title="Click here to enlarge" src="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-safari-300x102.jpg" alt="slickspeed-safari" width="300" height="102" /></a></p>
<p><a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-chrome.jpg" target="_blank">Chrome 1.0.154.48</a><br />
<a href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-chrome.jpg" target="_blank"><img class="alignnone size-medium wp-image-104" title="Click here to enlarge" src="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-chrome-300x113.jpg" alt="slickspeed-chrome" width="300" height="113" /></a> </p>
<p>No problem found in <a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-safari-nightly.jpg" target="_blank">Safari 3.1.2 Nightly</a>, <a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-firefox.jpg" target="_blank">Firefox 3.0.6</a>, <a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-opera.jpg" target="_blank">Opera 9.63</a> and <a title="View this screenshot" href="http://xing.web.id/blog/wp-content/uploads/2009/02/slickspeed-ie.jpg" target="_blank">IE7</a>.</p>
<p>Test the slickspeed here: <a href="http://xing.web.id/slickspeed/" target="_blank">http://xing.web.id/slickspeed/</a></p>
<p>Selectors I used:</p>
<ul>
<li>p:nth-child(even)</li>
<li>p:nth-child(n)[class] &gt; a</li>
<li>p:nth-child(even)</li>
<li>p:nth-child(n)[class] &gt; a</li>
<li>p:nth-child(even)</li>
<li>p:nth-child(n)[class] &gt; a</li>
<li>p:nth-child(even)</li>
<li>p:nth-child(n)[class] &gt; a</li>
<li>p:nth-child(even)</li>
<li>p:nth-child(n)[class] &gt; a</li>
</ul>
<p>JavaScript Frameworks I used:</p>
<ul>
<li><a href="http://jquery.com/" target="_blank">jQuery 1.2.6</a></li>
<li><a href="http://jquery.com/" target="_blank">jQuery 1.3.2</a></li>
<li><a href="http://www.dojotoolkit.org/" target="_blank">Dojo 1.2.3</a></li>
<li><a href="http://mootools.net/" target="_blank">MooTools 1.2.1</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xing.web.id/blog/2009/02/latest-jquery-v132s-bug-on-webkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP.JS &#8211; Use PHP functions in JavaScript</title>
		<link>http://xing.web.id/blog/2009/02/phpjs-use-php-functions-in-javascript/</link>
		<comments>http://xing.web.id/blog/2009/02/phpjs-use-php-functions-in-javascript/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 06:31:54 +0000</pubDate>
		<dc:creator>axing</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Library]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://xing.web.id/blog/?p=94</guid>
		<description><![CDATA[PHP.JS is an open source project in which to port PHP functions to JavaScript. The library is developed by Kevin van Zonneveld and his contributors, and they have been working hard in adding more functions into it. By including this library into your own web projects, you can use those higher-level PHP functions such as file_get_contents(), [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://phpjs.org/" target="_blank">PHP.JS</a> is an open source project in which to port PHP functions to JavaScript. The library is developed by <a href="http://kevin.vanzonneveld.net/" target="_blank">Kevin van Zonneveld</a> and <a href="http://phpjs.org/authors/index" target="_blank">his contributors</a>, and they have been working hard in adding more functions into it. By including this library into your own web projects, you can use those higher-level PHP functions such as <code>file_get_contents()</code>, <code>mktime()</code>, <code>serialize()</code>, etc which JavaScript doesn't support them natively.</p>
<p>Here is a piece of sample code of PHP's encryption function: <code>base64_encode()</code>:</p>
<div class="code-snippet">
<pre class="javascript"><span style="color: #003366; font-weight: bold;">function</span> base64_encode<span style="color: #66cc66;">&#40;</span> data <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">    <span style="color: #003366; font-weight: bold;">var</span> b64 = <span style="color: #3366CC;">&quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=&quot;</span>;</pre>
<pre class="javascript">    <span style="color: #003366; font-weight: bold;">var</span> o1, o2, o3, h1, h2, h3, h4, bits, i = ac = <span style="color: #CC0000;">0</span>, enc=<span style="color: #3366CC;">&quot;&quot;</span>, tmp_arr = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</pre>
<pre class="javascript">    data = utf8_encode<span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">do</span> <span style="color: #66cc66;">&#123;</span></pre>
<pre class="javascript">        o1 = data.<span style="color: #006600;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>i++<span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">        o2 = data.<span style="color: #006600;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>i++<span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">        o3 = data.<span style="color: #006600;">charCodeAt</span><span style="color: #66cc66;">&#40;</span>i++<span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">        bits = o1&lt;&lt;<span style="color: #CC0000;">16</span> | o2&lt;&lt;<span style="color: #CC0000;">8</span> | o3;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">        h1 = bits&gt;&gt;<span style="color: #CC0000;">18</span> &amp; 0x3f;</pre>
<pre class="javascript">        h2 = bits&gt;&gt;<span style="color: #CC0000;">12</span> &amp; 0x3f;</pre>
<pre class="javascript">        h3 = bits&gt;&gt;<span style="color: #CC0000;">6</span> &amp; 0x3f;</pre>
<pre class="javascript">        h4 = bits &amp; 0x3f;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">        tmp_arr<span style="color: #66cc66;">&#91;</span>ac++<span style="color: #66cc66;">&#93;</span> = b64.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>h1<span style="color: #66cc66;">&#41;</span> + b64.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>h2<span style="color: #66cc66;">&#41;</span> + b64.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>h3<span style="color: #66cc66;">&#41;</span> + b64.<span style="color: #006600;">charAt</span><span style="color: #66cc66;">&#40;</span>h4<span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">    <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #66cc66;">&#40;</span>i &lt; data.<span style="color: #006600;">length</span><span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">    enc = tmp_arr.<span style="color: #006600;">join</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span>;</pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">switch</span><span style="color: #66cc66;">&#40;</span> data.<span style="color: #006600;">length</span> % <span style="color: #CC0000;">3</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">1</span>:</pre>
<pre class="javascript">        enc = enc.<span style="color: #006600;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>, <span style="color: #CC0000;">-2</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">'=='</span>;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">break</span>;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">case</span> <span style="color: #CC0000;">2</span>:</pre>
<pre class="javascript">        enc = enc.<span style="color: #006600;">slice</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>, <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">'='</span>;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">break</span>;</pre>
<pre class="javascript">    <span style="color: #66cc66;">&#125;</span></pre>
<pre class="javascript">&nbsp;</pre>
<pre class="javascript">    <span style="color: #000066; font-weight: bold;">return</span> enc;</pre>
<pre class="javascript"><span style="color: #66cc66;">&#125;</span></pre>
</div>
<p>The library is available in 2 different packages:</p>
<ul>
<li><a href="http://phpjs.org/compiled/php.namespaced.js" target="_blank">Namespaced</a> (<a href="http://phpjs.org/compiled/php.namespaced.min.js" target="_blank">min</a>/<a href="http://phpjs.org/compiled/php.namespaced.packed.js" target="_blank">packed</a>)- all functions are contained in one object; and</li>
<li><a href="http://phpjs.org/compiled/php.js" target="_blank">Normal</a> (<a href="http://phpjs.org/compiled/php.min.js" target="_blank">min</a>/<a href="http://phpjs.org/compiled/php.packed.js" target="_blank">packed</a>)- just a collection of standalone functions.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xing.web.id/blog/2009/02/phpjs-use-php-functions-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery v1.3.0 has been released!</title>
		<link>http://xing.web.id/blog/2009/01/jquery-v130-has-been-released/</link>
		<comments>http://xing.web.id/blog/2009/01/jquery-v130-has-been-released/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 09:47:59 +0000</pubDate>
		<dc:creator>axing</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://xing.web.id/blog/?p=86</guid>
		<description><![CDATA[A long wait for this release, finally jQuery has released version 1.3 on its birthday (14 Jan).
New features on 1.3 are:

Replaced old CSS selector engine with Sizzle, a standalone framework which is developed by John Resig and donated to the Dojo Foundation.
A new event API, Live Events, that can binds event to the future DOM [...]]]></description>
			<content:encoded><![CDATA[<p>A long wait for this release, finally <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> has released version <a title="jQuery 1.3" href="http://docs.jquery.com/Release:jQuery_1.3" target="_blank">1.3</a> on its birthday (14 Jan).</p>
<p>New features on 1.3 are:</p>
<ul>
<li>Replaced old CSS selector engine with <a title="Sizzle" href="http://sizzlejs.com/" target="_blank">Sizzle</a>, a standalone framework which is developed by John Resig and donated to the <a title="Dojo Foundation" href="http://dojofoundation.org/" target="_blank">Dojo Foundation</a>.</li>
<li>A new event API, Live Events, that can binds event to the future DOM elements.</li>
</ul>
<p>Rewritten features are:</p>
<ul>
<li> Standardized jQuery Event according to <a title="W3C Standards" href="http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html" target="_blank">W3C standards</a> and makes it work smoothly across all browsers.</li>
<li>Rewritten HTML Injection, and it's 6x faster than before.</li>
<li>Rewritten .offset() from scratch, and it's 3x faster than before.</li>
<li>Deprecated browser sniffing API, replaced by a new technique called 'feature detection' that simulate a particular browser feature or bug to verify its existence. This feature detection is encapsulated into a new object, <a title="jQuery.support" href="http://docs.jquery.com/Utilities/jQuery.support" target="_blank">jQuery.support</a>.</li>
</ul>
<p>The release note of this version can be read at <a href="http://docs.jquery.com/Release:jQuery_1.3" target="_blank">here</a>.</p>
<p><strong>Trivia</strong>:</p>
<p>Version file size comparison:<br />
<a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.js" target="_blank">jQuery v1.3.0</a> (115KB), <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.3.min.js" target="_blank">minified</a> (53.7KB) and gzipped (17.8KB)<br />
<a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js" target="_blank">jQuery v1.2.6</a> (97.8KB), <a href="http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js" target="_blank">minified</a> (54.5KB) and gzipped (15.6KB)</p>
]]></content:encoded>
			<wfw:commentRss>http://xing.web.id/blog/2009/01/jquery-v130-has-been-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: Convert If to Switch</title>
		<link>http://xing.web.id/blog/2008/12/php-convert-if-to-switch/</link>
		<comments>http://xing.web.id/blog/2008/12/php-convert-if-to-switch/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 14:37:52 +0000</pubDate>
		<dc:creator>axing</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://xing.web.id/blog/?p=72</guid>
		<description><![CDATA[I have been being asked by some friends of mine, that is in PHP language how to convert If statement into Switch statement (in some cases, using Switch is for shortening code).
At first, I thought that Switch was just only for 'equal' comparison. But actually it is more than just equal. So I did a [...]]]></description>
			<content:encoded><![CDATA[<p>I have been being asked by some friends of mine, that is in PHP language how to convert <strong>If </strong>statement into <strong>Switch </strong>statement (in some cases, using Switch is for shortening code).</p>
<p>At first, I thought that Switch was just only for 'equal' comparison. But actually it is more than just equal. So I did a search, and I found there is a way that can code Switch just like If. Well, I'm lazy to explain, so let's see the following sample codes of getting Grade from Score:</p>
<p>If statement:</p>
<div class="code-snippet">
<pre class="php"><span style="color: #0000ff;">$score</span>=<span style="color: #cc66cc;">78</span>;</pre>
<pre class="php"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">85</span><span style="color: #66cc66;">&#41;</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade A&quot;</span>;</pre>
<pre class="php"><span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">70</span><span style="color: #66cc66;">&#41;</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade B&quot;</span>;</pre>
<pre class="php"><span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">55</span><span style="color: #66cc66;">&#41;</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade C&quot;</span>;</pre>
<pre class="php"><span style="color: #b1b100;">elseif</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#41;</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade D&quot;</span>;</pre>
<pre class="php"><span style="color: #b1b100;">else</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade E&quot;</span>;</pre>
<pre class="php"><span style="color: #b1b100;">endif</span>;</pre>
</div>
<p>Switch statement:</p>
<div class="code-snippet">
<pre class="php"><span style="color: #0000ff;">$score</span>=<span style="color: #cc66cc;">78</span>;</pre>
<pre class="php"><span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></pre>
<pre class="php">  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">85</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade A&quot;</span>; <span style="color: #b1b100;">break</span>;</pre>
<pre class="php">  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">70</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade B&quot;</span>; <span style="color: #b1b100;">break</span>;</pre>
<pre class="php">  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">55</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade C&quot;</span>; <span style="color: #b1b100;">break</span>;</pre>
<pre class="php">  <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">$score</span>&gt;=<span style="color: #cc66cc;">40</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade D&quot;</span>; <span style="color: #b1b100;">break</span>;</pre>
<pre class="php">  <span style="color: #000000; font-weight: bold;">default</span>: <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #ff0000;">&quot;Grade E&quot;</span>;</pre>
<pre class="php"><span style="color: #66cc66;">&#125;</span></pre>
</div>
<p>Both code produces same result, that is "Grade B". <img src='http://xing.web.id/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://xing.web.id/blog/2008/12/php-convert-if-to-switch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
