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";
}
`If string value(number) is less than 5 returns "Your number is less than 5!"
$st = strlen("game"); // returns 4
if ($st < 5 ) {
echo "Your number is less than 5!". "\n";
`
if number is more than 5, but less than 10 returns:
} elseif ($st < 10) {
echo "Your number is less than 10!". "\n";
`
And finally, if the number is higher than 10 returns:
} else {
echo "Your number is out of the range:("."\n";
}
`Hello world, This is sample text
Line2 Hello, world What's going On
We want to search string that contains: world & going
words
VISUAL STUDIO Example:
STEP 1: Press CTRL + F (Open find dialog)
STEP 2: Press ALT + R (Use Regular expression)
STEP 3: Write world(.*)going
in the search field
The search result will be:
Hello, world
What's going
On
because it contains the same time words "world" and "going"==
(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
integer
and float
values to write / update a variable value.
Simple Assignment
$y = 9;
$x = $y;
echo $x . "\n";
Addition
$x = 40; $y = 9;
$x += $y; // same as: $x = $x + $y
echo $x . "\n";
Subtraction
$x = 40; $y = 9;
$x -= $y; // $x = $x - $y
echo $x . "\n";
Multiplication
$x = 40; $y = 9;
$x *= $y; // $x = $x * $y
echo $x . "\n";
Division
$x = 40; $y = 9;
$x /= $y; // $x = $x / $y
echo $x . "\n";
Modulus
$x = 40; $y = 9;
$x %= $y; // $x = $x % $y
echo $x . "\n";
integer
and float
values to perform arithmetical operations.
Let's define two variables:
number1
and number2
and perform these operations$number1 = 40;
$number2 = 9;
Addition
echo $number1 + $number2 . "\n";
Subtraction
echo $number1 - $number2 . "\n";
Multiplication
echo $number1 * $number2 . "\n";
Division
echo $number1 / $number2 . "\n";
Modulus
echo $number1 % $number2 . "\n";