Posts

PHP MYSQL - Operators - 5.3 Comparison Operators

PHP Comparison Operators The PHP comparison operators are used to compare two values (number or string): Operator Name Example Result == Equal $x == $y Returns true if $x is equal to $y === Identical $x === $y Returns true if $x is equal to $y, and they are of the same type != Not equal $x != $y Returns true if $x is not equal to $y <> Not equal $x <> $y Returns true if $x is not equal to $y !== Not identical $x !== $y Returns true if $x is not equal to $y, or they are not of the same type > Greater than $x > $y Returns true if $x is greater than $y < Less than $x < $y Returns true if $x is less than $y >= Greater than or equal to $x >= $y Returns true if $x is greater than or equal to $y <= Less than or equal to $x <= $y Returns true if $x is less than or equal to $y Example ( ==) <!DOCTYPE html> <html> <body> <?php $x = 10;   $y = "10"; var_dump($x == $y); // returns true because values are equal ?>   </body>

PHP MYSQL - Operators - 5.2

  Assignment Same as... Description x = y x = y The left operand gets set to the value of the expression on the right x += y x = x + y Addition x -= y x = x - y Subtraction x *= y x = x * y Multiplication x /= y x = x / y Division x %= y x = x % y Modulus                          Ex: = <!DOCTYPE html> <html> <body> <?php $x = 100;   echo $x; ?>   </body> </html> Ex: += <!DOCTYPE html> <html> <body> <?php $x = 10;   $y = 20;  $x+=$y; echo $x; ?>   </body> </html> Video

PHP MYSQL - Operators - 5.1

Operators The Operator exhibits an operation $z = $x + $y here =, + are operators PHP divides the operators like Arithmetic operators Assignment operators Comparison operators Increment/Decrement operators Logical operators String operators Array operators Conditional assignment operators PHP Arithmetic Operators Operator Name Example Result + Addition $x + $y Sum of $x and $y - Subtraction $x - $y Difference of $x and $y * Multiplication $x * $y Product of $x and $y / Division $x / $y Quotient of $x and $y % Modulus $x % $y Remainder of $x divided by $y ** Exponentiation $x ** $y Result of raising $x to the $y'th power Ex: + <!DOCTYPE html> <html> <body> <?php $x = 10;   $y = 6; echo $x + $y; ?>   </body> </html> Ex: - <!DOCTYPE html> <html> <body> <?php $x = 10;   $y = 6; echo $x - $y; ?>   </body> </html> Ex: * <!DOCTYPE html> <html> <body> <?php $x = 10;   $y = 6; echo $x * $y; ?>