In this tutorial, you shall learn about Arithmetic Multiplication Operator in PHP, its syntax, and how to use this operator in PHP programs, with examples.

PHP Multiplication

PHP Arithmetic Multiplication Operator takes two numbers as operands and returns their product.

Symbol

* symbol is used for Multiplication Operator.

Syntax

The syntax for Multiplication Operator is

</>
Copy
operand_1 * operand_2

The operands could be of any numeric datatype, integer or float.

If the two operands are of different datatypes, implicit datatype promotion takes place and value of lower datatype is promoted to higher datatype.

Examples

1. Multiplication of Integers

In the following example, we take integer values in $x and $y, and find their product $x * $y using Arithmetic Multiplication Operator.

PHP Program

</>
Copy
<?php
  $x = 5;
  $y = 4;

  $output = $x * $y;

  echo "x = $x" . "<br>";
  echo "y = $y" . "<br>";
  echo "x * y = $output";
?>

Output