[DOC-BUGS] Logical Operators
[email protected] (Raju Mane) Sat, 25 Jan 2025 20:48:54 +0530
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <CAHNotAZmTtiqF8RnE4Fdbz_xYNW7Wv=2ppqH=KaZvup4XP7zVA@mail.gmail.com> |
--00000000000041ae06062c895de2
Content-Type: text/plain; charset="UTF-8"
Respected sir,
My self Mr. Raju Ramchandra Mane. I am an Assistant Professor. I am from
India. Right now I am teaching the PHP programming language. I used the
latest version of PHP, which is version 8.4. I find that some of the
logical operators are not showing the exact result of what they are
supposed to do. for example lets say
$a=10;
$b=20;
$c=30;
$e=40;
echo "and operator<br>";
$res1= $a<$b and $b>$e;
echo "$res1<br>";
The expected output should be false(0) but it's showing the true(1). Why is
it so?
Along with these operators some of the result in or operator and xor
operator.
Please see the below code. And tell us what is wrong with these operators.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h1>Logical Operators</h1>
<?php
$a=10;
$b=20;
$c=30;
$e=40;
$f=0;
// expected output should be false(0) but it's showing the true(1)
echo "and operator<br>";
$res1= $a<$b and $b>$e;
echo "$res1<br>";
echo "or operator<br>";
// expected output should be true(1) but it's showing the false(0)
$res2=$a>$b or $b<$e;
echo "$res2<br>";
echo "xor operator<br>";
// expected output should be false(0) but it's showing the true(1)
$res3=$a<$b xor $b<$e;
echo "$res3<br>";
// expected output should be true(1) but it's showing the false(0)
$res4=$a>$b xor $b<$e;
echo "$res4<br>";
?>
</body>
</html>
Please let me know of any further discussion..
Thank You,
Mr. Raju Ramchandra Mane
(Assistant Professor)
--00000000000041ae06062c895de2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Respected sir,<div>My self=C2=A0Mr. Raju Ramchandra Mane. =
I am an Assistant Professor. I am from India. Right now I am teaching the P=
HP programming language. I used the latest version of PHP, which is version=
8.4. I find that some of the logical operators are not showing the exact r=
esult of what they are supposed to do. for example lets say</div><div><br><=
/div><div><div style=3D"font-family:Consolas,"Courier New",monosp=
ace;font-size:18px;line-height:24px"><div style=3D"color:rgb(59,59,59)"><sp=
an style=3D"color:rgb(0,16,128)">$a</span><span style=3D"color:rgb(0,0,0)">=
=3D</span><span style=3D"color:rgb(9,134,88)">10</span><span style=3D"color=
:rgb(0,0,0)">;</span></div><div style=3D"color:rgb(59,59,59)"><span style=
=3D"color:rgb(0,16,128)">$b</span><span style=3D"color:rgb(0,0,0)">=3D</spa=
n><span style=3D"color:rgb(9,134,88)">20</span><span style=3D"color:rgb(0,0=
,0)">;</span></div><div style=3D"color:rgb(59,59,59)"><span style=3D"color:=
rgb(0,16,128)">$c</span><span style=3D"color:rgb(0,0,0)">=3D</span><span st=
yle=3D"color:rgb(9,134,88)">30</span><span style=3D"color:rgb(0,0,0)">;</sp=
an></div><div style=3D"color:rgb(59,59,59)"><span style=3D"color:rgb(0,16,1=
28)">$e</span><span style=3D"color:rgb(0,0,0)">=3D</span><span style=3D"col=
or:rgb(9,134,88)">40</span><span style=3D"color:rgb(0,0,0)">;</span></div><=
div style=3D"color:rgb(59,59,59)"><span style=3D"color:rgb(121,94,38)">echo=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(16=
3,21,21)">"and operator<br>"</span><span style=3D"color:rgb=
(0,0,0)">;</span></div><div style=3D"color:rgb(59,59,59)"><span style=3D"co=
lor:rgb(0,16,128)">$res1</span><span style=3D"color:rgb(0,0,0)">=3D </span>=
<span style=3D"color:rgb(0,16,128)">$a</span><span style=3D"color:rgb(0,0,0=
)"><</span><span style=3D"color:rgb(0,16,128)">$b</span><span style=3D"c=
olor:rgb(0,0,0)"> and </span><span style=3D"color:rgb(0,16,128)">$b</span><=
span style=3D"color:rgb(0,0,0)">></span><span style=3D"color:rgb(0,16,12=
8)">$e</span><span style=3D"color:rgb(0,0,0)">;</span></div><div><div style=
=3D"line-height:24px"><div style=3D"color:rgb(59,59,59)"><span style=3D"col=
or:rgb(121,94,38)">echo</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(163,21,21)">"</span><span style=3D"color:rgb(0,16=
,128)">$res1</span><span style=3D"color:rgb(163,21,21)"><br>"</s=
pan><span style=3D"color:rgb(0,0,0)">;</span></div><div><font color=3D"#000=
000">The expected output should be false(0) but it's showing the true(1=
). Why is it so? </font></div><div><font color=3D"#000000">Along with these=
operators some of the result in or operator and xor operator.</font></div>=
<div><font color=3D"#000000">Please see the below code. And tell us what is=
wrong with these operators.</font></div><div><br></div><div><div style=3D"=
color:rgb(59,59,59);line-height:24px"><div><span style=3D"color:rgb(128,0,0=
)"><!DOCTYPE</span> <span style=3D"color:rgb(229,0,0)">html</span><span =
style=3D"color:rgb(128,0,0)">></span></div><div><span style=3D"color:rgb=
(128,0,0)"><html</span> <span style=3D"color:rgb(229,0,0)">lang</span>=
=3D<span style=3D"color:rgb(0,0,255)">"en"</span><span style=3D"c=
olor:rgb(128,0,0)">></span></div><div><span style=3D"color:rgb(128,0,0)"=
><head></span></div><div>=C2=A0 =C2=A0 <span style=3D"color:rgb(128,0=
,0)"><meta</span> <span style=3D"color:rgb(229,0,0)">charset</span>=3D<s=
pan style=3D"color:rgb(0,0,255)">"UTF-8"</span><span style=3D"col=
or:rgb(128,0,0)">></span></div><div>=C2=A0 =C2=A0 <span style=3D"color:r=
gb(128,0,0)"><meta</span> <span style=3D"color:rgb(229,0,0)">name</span>=
=3D<span style=3D"color:rgb(0,0,255)">"viewport"</span> <span sty=
le=3D"color:rgb(229,0,0)">content</span>=3D<span style=3D"color:rgb(0,0,255=
)">"width=3Ddevice-width, initial-scale=3D1.0"</span><span style=
=3D"color:rgb(128,0,0)">></span></div><div>=C2=A0 =C2=A0 <span style=3D"=
color:rgb(128,0,0)"><title></span>Document<span style=3D"color:rgb(12=
8,0,0)"></title></span></div><div><span style=3D"color:rgb(128,0,0)">=
</head></span></div><div><span style=3D"color:rgb(128,0,0)"><body&=
gt;</span></div><div>=C2=A0 =C2=A0 <span style=3D"color:rgb(128,0,0)"><h=
1></span>Logical Operators<span style=3D"color:rgb(128,0,0)"></h1>=
</span></div><div>=C2=A0 =C2=A0 <span style=3D"color:rgb(128,0,0)"><?php=
</span></div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 </span><span style=3D"color:rgb(0,16,128)">$a</span><span style=3D"colo=
r:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(9,134,88)">10</span><span =
style=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0,=
0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,16,128)">=
$b</span><span style=3D"color:rgb(0,0,0)">=3D</span><span style=3D"color:rg=
b(9,134,88)">20</span><span style=3D"color:rgb(0,0,0)">;</span></div><div><=
span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span st=
yle=3D"color:rgb(0,16,128)">$c</span><span style=3D"color:rgb(0,0,0)">=3D</=
span><span style=3D"color:rgb(9,134,88)">30</span><span style=3D"color:rgb(=
0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,16,128)">$e</span><span sty=
le=3D"color:rgb(0,0,0)">=3D</span><span style=3D"color:rgb(9,134,88)">40</s=
pan><span style=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"colo=
r:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0=
,16,128)">$f</span><span style=3D"color:rgb(0,0,0)">=3D</span><span style=
=3D"color:rgb(9,134,88)">0</span><span style=3D"color:rgb(0,0,0)">;</span><=
/div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </sp=
an><span style=3D"color:rgb(0,128,0)">// expected output should be false(0)=
but it's showing the true(1)</span></div><div><span style=3D"color:rgb=
(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(121,94=
,38)">echo</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"co=
lor:rgb(163,21,21)">"and operator<br>"</span><span style=3D=
"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0,0)">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,16,128)">$res1</=
span><span style=3D"color:rgb(0,0,0)">=3D </span><span style=3D"color:rgb(0=
,16,128)">$a</span><span style=3D"color:rgb(0,0,0)"><</span><span style=
=3D"color:rgb(0,16,128)">$b</span><span style=3D"color:rgb(0,0,0)"> and </s=
pan><span style=3D"color:rgb(0,16,128)">$b</span><span style=3D"color:rgb(0=
,0,0)">></span><span style=3D"color:rgb(0,16,128)">$e</span><span style=
=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0,0)">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(121,94,38)">ech=
o</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(1=
63,21,21)">"</span><span style=3D"color:rgb(0,16,128)">$res1</span><sp=
an style=3D"color:rgb(163,21,21)"><br>"</span><span style=3D"col=
or:rgb(0,0,0)">;</span></div><br><div><span style=3D"color:rgb(0,0,0)">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(121,94,38)">echo</=
span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(163,=
21,21)">"or operator<br>"</span><span style=3D"color:rgb(0,=
0,0)">;</span></div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color:rgb(0,128,0)">// expected output sho=
uld be true(1) but it's showing the false(0)</span></div><div><span sty=
le=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"c=
olor:rgb(0,16,128)">$res2</span><span style=3D"color:rgb(0,0,0)">=3D</span>=
<span style=3D"color:rgb(0,16,128)">$a</span><span style=3D"color:rgb(0,0,0=
)">></span><span style=3D"color:rgb(0,16,128)">$b</span><span style=3D"c=
olor:rgb(0,0,0)"> or </span><span style=3D"color:rgb(0,16,128)">$b</span><s=
pan style=3D"color:rgb(0,0,0)"><</span><span style=3D"color:rgb(0,16,128=
)">$e</span><span style=3D"color:rgb(0,0,0)">;</span></div><div><span style=
=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"col=
or:rgb(121,94,38)">echo</span><span style=3D"color:rgb(0,0,0)"> </span><spa=
n style=3D"color:rgb(163,21,21)">"</span><span style=3D"color:rgb(0,16=
,128)">$res2</span><span style=3D"color:rgb(163,21,21)"><br>"</s=
pan><span style=3D"color:rgb(0,0,0)">;</span></div><br><div><span style=3D"=
color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:r=
gb(121,94,38)">echo</span><span style=3D"color:rgb(0,0,0)"> </span><span st=
yle=3D"color:rgb(163,21,21)">"xor operator<br>"</span><span=
style=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0=
,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,128,0)">=
// expected output should be false(0) but it's showing the true(1)</spa=
n></div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 <=
/span><span style=3D"color:rgb(0,16,128)">$res3</span><span style=3D"color:=
rgb(0,0,0)">=3D</span><span style=3D"color:rgb(0,16,128)">$a</span><span st=
yle=3D"color:rgb(0,0,0)"><</span><span style=3D"color:rgb(0,16,128)">$b<=
/span><span style=3D"color:rgb(0,0,0)"> xor </span><span style=3D"color:rgb=
(0,16,128)">$b</span><span style=3D"color:rgb(0,0,0)"><</span><span styl=
e=3D"color:rgb(0,16,128)">$e</span><span style=3D"color:rgb(0,0,0)">;</span=
></div><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </=
span><span style=3D"color:rgb(121,94,38)">echo</span><span style=3D"color:r=
gb(0,0,0)"> </span><span style=3D"color:rgb(163,21,21)">"</span><span =
style=3D"color:rgb(0,16,128)">$res3</span><span style=3D"color:rgb(163,21,2=
1)"><br>"</span><span style=3D"color:rgb(0,0,0)">;</span></div><=
br><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span=
><span style=3D"color:rgb(0,128,0)">// expected output should be true(1) bu=
t it's showing the false(0)</span></div><div><span style=3D"color:rgb(0=
,0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,16,128=
)">$res4</span><span style=3D"color:rgb(0,0,0)">=3D</span><span style=3D"co=
lor:rgb(0,16,128)">$a</span><span style=3D"color:rgb(0,0,0)">></span><sp=
an style=3D"color:rgb(0,16,128)">$b</span><span style=3D"color:rgb(0,0,0)">=
xor </span><span style=3D"color:rgb(0,16,128)">$b</span><span style=3D"col=
or:rgb(0,0,0)"><</span><span style=3D"color:rgb(0,16,128)">$e</span><spa=
n style=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,=
0,0)">=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:rgb(121,94,38=
)">echo</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color=
:rgb(163,21,21)">"</span><span style=3D"color:rgb(0,16,128)">$res4</sp=
an><span style=3D"color:rgb(163,21,21)"><br>"</span><span style=
=3D"color:rgb(0,0,0)">;</span></div><div><span style=3D"color:rgb(0,0,0)">=
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(128,0,0)">?</span><span style=
=3D"color:rgb(128,0,0)">></span></div><div><span style=3D"color:rgb(128,=
0,0)"></body></span></div><div><span style=3D"color:rgb(128,0,0)"><=
;/html></span></div></div><div><br></div>Please let me know of any furth=
er discussion.. </div><div>Thank You,</div><div>Mr. Raju Ramchandra Mane</d=
iv><div>(Assistant Professor)</div></div></div></div></div></div>
--00000000000041ae06062c895de2--