==
(Equal)
Returns true if $x is equal to $y
$x = 40;
$y = "40";
var_dump($x == $y); // true
===
(Identical)
Returns true if $x is equal to $y, and they are of the same type
$x = 40;
$y = "40";
var_dump($x === $y); // false
!=
(Not equal)
Returns true if $x is not equal to $y
$x = 40;
$y = "40";
var_dump($x != $y); // false
<>
(Not equal)
Returns true if $x is not equal to $y
$x = 40;
$y = "40";
var_dump($x <> $y); // false
!==
(Not identical)
Returns true if $x is not equal to $y, or they are not of the same type
$x = 40;
$y = "40";
var_dump($x !== $y); // true
>
(Greater than)
Returns true if $x is greater than $y
$x = 40;
$y = 50;
var_dump($x > $y); // false
<
(Less than)
Returns true if $x is less than $y
$x = 40;
$y = 50;
var_dump($x < $y); // true
>=
(Greater than or equal to)
Returns true if $x is greater than or equal to $y
$x = 40;
$y = 50;
var_dump($x >= $y); // false
<=
(Less than or equal to)
Returns true if $x is less than or equal to $y
$x = 40;
$y = 50;
var_dump($x <= $y); // true
and
($x and $y)
True if both $x and $y are true
$x = 40;
$y = 50;
if ($x > 30 and $y > 45) {
echo "True";
}
or
($x or $y)
True if either $x or $y is true
$x = 40;
$y = 50;
if ($x > 30 or $y == 85) {
echo "True";
}
xor
($x xor $y)
True if either $x or $y is true, but not both
$x = 40;
$y = 50;
if ($x > 30 xor $y == 85) {
echo "True";
}
&&
($x && $y)
True if both $x and $y are true
$x = 40;
$y = 50;
if ($x > 30 and $y > 45) {
echo "True";
}
||
($x || $y)
True if either $x or $y is true
$x = 40;
$y = 50;
if ($x > 30 or $y == 85) {
echo "True";
}
!
(!$x)
True if $x is not true
$x = 40;
if ($x !== 50) {
echo "True";
}
break
statement is used to jump out of loops
for ($x = 0; $x < 10; $x++) {
if ($x == 7) {
break;
}
echo "$x"."\n";
}
Another example using break
statement
In this example prints numbers less than 6
for ($x = 0; $x < 10; $x++) {
if ($x*$x > 30) {
break;
}
echo "$x"."\n";
}
Uses break
statement instead of for loop condition section
for ($i = 0; ; $i ++) {
if ($i == 10) {
break;
}
echo $i . "\n";
}
continue
statement breaks only one iteration in the loop and continues with the next iterationfor ($x = 0; $x < 10; $x++) {
if ($x == 7) {
continue;
}
echo "$x"."\n";
}
echo "\n\n";
Prints Only numbers evenly divisible by 2
for ($x = 0; $x < 10; $x++) {
if ($x%2 == 1) {
continue;
}
echo "Example2: $x"."\n";
}