In this tutorial, you shall learn about Division Assignment Operator, its syntax, and how to use this operator in programs, with examples.
PHP – Division Assignment Operator
Division assignment operator is used to decrease the value in a variable by given number of times.
The operator takes two operands, and assigns the division of first operand by the second operand to the first operand.
Syntax
The syntax of using Division Assignment Operator is
operand1 /= operand2
The operation would be similar to the following statement.
operand1 = operand1 / operand2
which translates to the meaning of decreasing 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 Division Assignment Operator to decrease the value in variable $x
by 10
times.
PHP Program
<?php
$x = 42;
$x /= 10;
print_r("After division assignment, x is {$x}.");
?>
Output
Conclusion
In this PHP Tutorial, we learned about Division Assignment Operator, and how to use it to decrease the value in a variable by given number of times.