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


OperatorNameExampleResult
+Addition$x + $ySum of $x and $y
-Subtraction$x - $yDifference of $x and $y
*Multiplication$x * $yProduct of $x and $y
/Division$x / $yQuotient of $x and $y
%Modulus$x % $yRemainder of $x divided by $y
**Exponentiation$x ** $yResult 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;
?>  
</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;
?>  
</body>
</html>

Ex: **

<!DOCTYPE html>
<html>
<body>
<?php
$x = 10;  
$y = 3;
echo $x ** $y;
?>  
</body>
</html>



For Video Lesson Click here Video

Popular posts from this blog

COPA Bits for Computer Based Test (CBT) by Venugopal Vanjarapu

COPA

Web Designing course - HTML, CSS live classes