July 11, 2017

Core PHP: Arithmetic Operators (3.0)

Operators

Operators carry out operations on variables and values.

Example: operand and operator

Arithmetic Operators

Arithmetic operators work with numeric values to perform common arithmetical operations.

Example:
<?php
  $num1 = 8;
  $num2 = 6;

  //Addition
  echo $num1 + $num2; //14

  //Subtraction
  echo $num1 - $num2; //2

  //Multiplication
  echo $num1 * $num2; //48

  //Division
   echo $num1 / $num2; //1.33333333333
?>

No comments:

Post a Comment