<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Don&#8217;t use &#8220;and&#8221; and &#8220;or&#8221; logical operator in PHP, it has flaw</title>
	<atom:link href="http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/feed" rel="self" type="application/rss+xml" />
	<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html</link>
	<description>Useful Tutorials, Scripts , Tips, and Resources for all PHP and Ajax beginners and experts .</description>
	<lastBuildDate>Sun, 14 Mar 2010 01:15:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Pooja</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-4966</link>
		<dc:creator>Pooja</dc:creator>
		<pubDate>Wed, 23 Dec 2009 06:23:47 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-4966</guid>
		<description>The basic logic for using the logical operators in any of language especially works same as the semiconductor Gates.If anyone who is aware of semiconductors gates ,then he/she can truely can say that this is not an flaw.
this is the And Gate truth table
INPUT 	OUTPUT
A 	B 	A AND B
0 	0 	0
0 	1 	0
1 	0 	0
1 	1 	1

and this is the or gate truth table

INPUT 	OUTPUT
A 	B 	A OR B
0 	0 	0
0 	1 	1
1 	0 	1
1 	1 	1

if 1 is true and 0 is false
then tracing accordingly ,will find that PHP returns the correct answer.So I guess,its not a flaw.....</description>
		<content:encoded><![CDATA[<p>The basic logic for using the logical operators in any of language especially works same as the semiconductor Gates.If anyone who is aware of semiconductors gates ,then he/she can truely can say that this is not an flaw.<br />
this is the And Gate truth table<br />
INPUT 	OUTPUT<br />
A 	B 	A AND B<br />
0 	0 	0<br />
0 	1 	0<br />
1 	0 	0<br />
1 	1 	1</p>
<p>and this is the or gate truth table</p>
<p>INPUT 	OUTPUT<br />
A 	B 	A OR B<br />
0 	0 	0<br />
0 	1 	1<br />
1 	0 	1<br />
1 	1 	1</p>
<p>if 1 is true and 0 is false<br />
then tracing accordingly ,will find that PHP returns the correct answer.So I guess,its not a flaw&#8230;..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: svnlabs</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-4778</link>
		<dc:creator>svnlabs</dc:creator>
		<pubDate>Tue, 03 Nov 2009 19:00:42 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-4778</guid>
		<description>Great Articles here...
Awesome!!
I will be a regular user of this site :)

svnlabs</description>
		<content:encoded><![CDATA[<p>Great Articles here&#8230;<br />
Awesome!!<br />
I will be a regular user of this site <img src='http://roshanbh.com.np/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>svnlabs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-3650</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Fri, 13 Mar 2009 14:34:15 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-3650</guid>
		<description>The logical operators work fine in PHP when you use sound logic to test them. I use them all the time. As Khalid said, not understanding precedence is not a &quot;flaw&quot; in php, it is a lack of understanding on your part. Khalid should have updated his &quot;prints&quot; comments on the code he posted like so.

$return_val = (false or true);
var_dump($return_val); //prints bool(true)

$return_val = (true and false);
var_dump($return_val); //prints bool(false)

Again, basic logic... not a flaw... I hope you have not confused the crap out of anyone else with this.</description>
		<content:encoded><![CDATA[<p>The logical operators work fine in PHP when you use sound logic to test them. I use them all the time. As Khalid said, not understanding precedence is not a &#8220;flaw&#8221; in php, it is a lack of understanding on your part. Khalid should have updated his &#8220;prints&#8221; comments on the code he posted like so.</p>
<p>$return_val = (false or true);<br />
var_dump($return_val); //prints bool(true)</p>
<p>$return_val = (true and false);<br />
var_dump($return_val); //prints bool(false)</p>
<p>Again, basic logic&#8230; not a flaw&#8230; I hope you have not confused the crap out of anyone else with this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jimmy</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-3429</link>
		<dc:creator>jimmy</dc:creator>
		<pubDate>Wed, 31 Dec 2008 06:00:55 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-3429</guid>
		<description>maybe this flaw in individually release of php</description>
		<content:encoded><![CDATA[<p>maybe this flaw in individually release of php</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: What The Heck Is PHP? : ProfitableSistas</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-2046</link>
		<dc:creator>What The Heck Is PHP? : ProfitableSistas</dc:creator>
		<pubDate>Thu, 28 Aug 2008 06:10:34 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-2046</guid>
		<description>[...] Don’t use “and” and “or” logical operator in PHP, it has flaw - Today, When I was doing some programming stuffs and I found out that there is serious flaw in the “and” , “or” logical operator of PHP. I’m not talking about the symbol “&#124;&#124;” and “&amp;&amp;” logical operator. I’m talking about the “and” and &#8230;   Share and Enjoy: [...]</description>
		<content:encoded><![CDATA[<p>[...] Don’t use “and” and “or” logical operator in PHP, it has flaw &#8211; Today, When I was doing some programming stuffs and I found out that there is serious flaw in the “and” , “or” logical operator of PHP. I’m not talking about the symbol “||” and “&amp;&amp;” logical operator. I’m talking about the “and” and &#8230;   Share and Enjoy: [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roshan</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1251</link>
		<dc:creator>Roshan</dc:creator>
		<pubDate>Sat, 21 Jun 2008 15:20:02 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1251</guid>
		<description>ya U saw that link...as you can see you can see the undesired result due to precedence of the operator...</description>
		<content:encoded><![CDATA[<p>ya U saw that link&#8230;as you can see you can see the undesired result due to precedence of the operator&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khalid</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1232</link>
		<dc:creator>khalid</dc:creator>
		<pubDate>Thu, 19 Jun 2008 05:18:20 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1232</guid>
		<description>My PHP version is &quot;5.2.6&quot;.
We need to go through the below link.

http://in.php.net/manual/en/language.operators.logical.php</description>
		<content:encoded><![CDATA[<p>My PHP version is &#8220;5.2.6&#8243;.<br />
We need to go through the below link.</p>
<p><a href="http://in.php.net/manual/en/language.operators.logical.php" rel="nofollow">http://in.php.net/manual/en/language.operators.logical.php</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roshan</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1231</link>
		<dc:creator>Roshan</dc:creator>
		<pubDate>Thu, 19 Jun 2008 04:33:17 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1231</guid>
		<description>hey Khalid....which PHP version u&#039;re using? I&#039;m using PHP5 and the above result is absolutely correct, I&#039;ve tested it 3-4 times in PHP5...
better check your result once man....</description>
		<content:encoded><![CDATA[<p>hey Khalid&#8230;.which PHP version u&#8217;re using? I&#8217;m using PHP5 and the above result is absolutely correct, I&#8217;ve tested it 3-4 times in PHP5&#8230;<br />
better check your result once man&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khalid</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1230</link>
		<dc:creator>khalid</dc:creator>
		<pubDate>Wed, 18 Jun 2008 21:12:01 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1230</guid>
		<description>the above commented result is wrong, i think u got the funda.</description>
		<content:encoded><![CDATA[<p>the above commented result is wrong, i think u got the funda.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khalid</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1228</link>
		<dc:creator>khalid</dc:creator>
		<pubDate>Wed, 18 Jun 2008 21:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1228</guid>
		<description>$return_val = (false or true);
var_dump($return_val);  //prints bool(false)

$return_val = (true and false);
var_dump($return_val);  //prints bool(true)</description>
		<content:encoded><![CDATA[<p>$return_val = (false or true);<br />
var_dump($return_val);  //prints bool(false)</p>
<p>$return_val = (true and false);<br />
var_dump($return_val);  //prints bool(true)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khalid</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1227</link>
		<dc:creator>khalid</dc:creator>
		<pubDate>Wed, 18 Jun 2008 21:04:07 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1227</guid>
		<description>Use logical AND and OR operator always in brackets ( ) , it will give you the proper result.
PHP does not have any flaws regarding it.

Your code should be like this :



Enjoy !</description>
		<content:encoded><![CDATA[<p>Use logical AND and OR operator always in brackets ( ) , it will give you the proper result.<br />
PHP does not have any flaws regarding it.</p>
<p>Your code should be like this :</p>
<p>Enjoy !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Roshan</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1211</link>
		<dc:creator>Roshan</dc:creator>
		<pubDate>Tue, 17 Jun 2008 16:18:39 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1211</guid>
		<description>@Bijay - Thanks man...I&#039;ve just using it and got this undesired result and wanted alert everyone..

@Alexa - thanks for explanation...a beginner developer may really be in dilemma if they use the example in the way I did..the priority of &quot;and&quot; , &quot;or&quot; operator is really awful compared to assignment operator...</description>
		<content:encoded><![CDATA[<p>@Bijay &#8211; Thanks man&#8230;I&#8217;ve just using it and got this undesired result and wanted alert everyone..</p>
<p>@Alexa &#8211; thanks for explanation&#8230;a beginner developer may really be in dilemma if they use the example in the way I did..the priority of &#8220;and&#8221; , &#8220;or&#8221; operator is really awful compared to assignment operator&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex@Net</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1205</link>
		<dc:creator>Alex@Net</dc:creator>
		<pubDate>Tue, 17 Jun 2008 11:58:33 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1205</guid>
		<description>Priotiry of the OR operator is less then =.
So $return_val = false or true; will be evaluated as: ($return_val = false) or true;
OR is usefull when you need to write something like this:
$var = $var1 or $var = $var2 or $var = $var3;
which is a shortcut to:
if ($var1) $var = $var1 elseif ($var2) ...</description>
		<content:encoded><![CDATA[<p>Priotiry of the OR operator is less then =.<br />
So $return_val = false or true; will be evaluated as: ($return_val = false) or true;<br />
OR is usefull when you need to write something like this:<br />
$var = $var1 or $var = $var2 or $var = $var3;<br />
which is a shortcut to:<br />
if ($var1) $var = $var1 elseif ($var2) &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bijay Rungta</title>
		<link>http://roshanbh.com.np/2008/06/flaw-in-and-or-logical-operator-php.html/comment-page-1#comment-1204</link>
		<dc:creator>Bijay Rungta</dc:creator>
		<pubDate>Tue, 17 Jun 2008 10:28:46 +0000</pubDate>
		<guid isPermaLink="false">http://roshanbh.com.np/?p=129#comment-1204</guid>
		<description>Cool Stuff..
Good that I never used them as far as I can remember...

I dug this Story..

http://digg.com/programming/Flaw_in_and_and_or_logical_operator_in_PHP</description>
		<content:encoded><![CDATA[<p>Cool Stuff..<br />
Good that I never used them as far as I can remember&#8230;</p>
<p>I dug this Story..</p>
<p><a href="http://digg.com/programming/Flaw_in_and_and_or_logical_operator_in_PHP" rel="nofollow">http://digg.com/programming/Flaw_in_and_and_or_logical_operator_in_PHP</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
