Use arithmetic operator in PHP

Description

The following code shows how to use arithmetic operator.

Example


<?php/* www  .j a  v a2 s . co m*/
  //prints 6
  print(2 + 2 * 2);
  print("<br>\n");

  //prints 2.5
  print(5 / 2);
  print("<br>\n");

  //prints 1
  print(5 % 2);
  print("<br>\n");

  //prints 35
  print(" 7 little Indians" * 5);
  print("<br>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition