In PHP, conditional statements are a fundamental part of building effective websites that are customised with preferences or that require a login. In fact there are many uses for conditional statements in PHP.
In PHP a condition is typed as a boolean type. The simplest conditions are true
and false
, but more complex conditions also return these as results.
There are several operators that can be used:
Symbol  Name  Returns true when 

<  Less than 
$a is less than $b .

>  Greater than 
$a is greater than $b .

<=  Less than or equal to 
$a is less than or equal to $b .

>=  Greater than or equal to 
$a is greater than or equal to $b .

==  Equal to 
$a is equal to $b .

!=  Not equal to 
$a is not equal to $b .

<>  Not equal 
$a is not equal to $b .

===  Identical 
$a and $b are the same and are the same type.

!==  Not identical 
$a and $b are not the same or are not the same type.

These operators are easy to use:
<?php $x = 5; $y = 7; $z = 0; $z = $x < $y; echo($z); $z = $x > $y; echo($z); $z = $x <= $y; echo($z); $z = $x >= $y; echo($z); $z = $x == $y; echo($z); $z = $x != $y; echo($z); ?>
Propositional logic which programming languages such as PHP use can also join multiple conditions through logical conjunction and logical disjunction. These are better known as AND and OR.
AND and OR are based on AND gates and OR gates in computer hardware.
AND requires that two conditions are true to return true.
The following is a truth table for AND:
P  Q  P AND Q 

true  true  true 
true  false  false 
false  true  false 
false  false  false 
In PHP the AND symbol is &&
. The following is an example using AND in a condition:
<?php $r = false; $p = true; $q = false; $r = true; $result = $p && $q; echo($result); $result = $p && $r; echo($result); ?>
OR requires that one of the two conditions is true to return true.
The following is the truth table for OR:
P  Q  P OR Q 

true  true  true 
true  false  true 
false  true  true 
false  false  false 
In PHP the OR symbol is 
. The following is an example using OR in a condition:
<?php $r = false; $p = false; $q = false; $r = true; $result = $p  $q; echo($result); $result = $p  $r; echo($result); >?
The final type of logical operator is the NOT operator. The truth table following shows how NOT performs.
P  NOT P 

true  false 
false  true 
In PHP, NOT is represented with the !
operator. Putting a NOT operator in front of
a boolean value will invert it. The following is a condition that uses
the NOT operator to flip the value of a boolean value:
<?php $x = false; $y = true; echo(!$x); echo(!$y); ?>
A key law in logic is De Morgan's Law. This law shows:
Less formally:
!($A && $B)
== !$A  !$B
!($A  $B)
== !$A && !$B
The truth table for !($A && $B)
and !$A  !$B
is as follows:
$A  $B  $A && $B  !($A && $B)  !$A  !$B 

true  true  true  false  false 
true  false  false  true  true 
false  true  false  true  true 
false  false  false  true  true 
Now in PHP:
<?php $A = true; $B = false; echo(!($A && $B)); echo(!$A  !$B); ?>
Now the truth table for !($A  $B)
and !$B
is as follows:
$A  $B  $A  $B  !($A  $B)  !$A && !$B 

true  true  true  false  false 
true  false  true  false  false 
false  true  true  false  false 
false  false  false  true  true 
Now in PHP:
<?php $A = true; $B = false; echo(!($A  $B)); echo(!$A && !$B); ?>
ZPE 1.6.7 is now available to download. It's free too!
I was at first a bit worried that #PokemonLetsGoEevee was going to be a let down but still went ahead and bought it… https://t.co/60LVeA6AOZ 3 days ago 
Retweet @CarlosMatos80: Bitconnect Wasnt Just A Coin, It Was A Revolution Against The Establishment And Criminals
With A Card This Big It Is Im…11 days ago 
Wow! I can’t put it in words but my favourite game of all time, #warcraft3 is being remastered as #WarcraftReforged… https://t.co/63dEem2WSn 18 days ago 
I was right. In fact, it's pretty much confirmed in the keynote  they use SODIMMs. 19 days ago 
There’s only one CPU with the specs of the top #MacMini2018 CPU which suggests to me that it uses an Intel Core i7… https://t.co/6EM7rvTsOg 19 days ago 