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

PHP – Multiplication Assignment Operator

Multiplication assignment operator is used to increase the value in a variable by given number of times.

The operator takes two operands, and assigns the product of both the operands to the first operand.

Syntax

The syntax of using Multiplication Assignment Operator is

</>
Copy
operand1 *= operand2

The operation would be similar to the following statement.

</>
Copy
operand1 = operand1 * operand2

which translates to the meaning of increasing the value of operand1 by operand2 times.

We can use variable for operand1; variable or value for operand2.

Example

In the following example, we use Multiplication Assignment Operator to increase the value in variable $x by 10 times.

PHP Program

</>
Copy
<?php
$x = 41;
$x *= 10;
print_r("After multiplication assignment, x is {$x}.");
?>

Output

PHP - Multiplication Assignment Operator

Conclusion

In this PHP Tutorial, we learned about Multiplication Assignment Operator, and how to use it to increase the value in a variable by given number of times.