Home > Article > Backend Development > How to implement multiplication in php
In PHP, you can use the "*" arithmetic operator to implement multiplication. This operator is used to calculate the product of the two numbers before and after. The syntax is "multiplier 1*multiplier 2".
The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer
Operator refers to certain symbols that generate another value through one or more expressions, such as " ", "%", ".", etc. are all operators.
In the expression 2 1, the operator " " has two operands, 1 and 2. An operator with two operands can be called a binary operator, and an operator with one operand is called a unary operator. For example, in the expression -6, the operator "-" has only one operand 6, so the "-" here is a unary operator.
Next, I will give you a brief introduction to the commonly used operators in PHP.
Arithmetic Operators
The Arithmetic Operators operator is a symbol that handles the four arithmetic operations (addition, subtraction, multiplication, and division) and is most commonly used in number processing.
The following table:
The example is as follows:
<?php $x=10; $y=6; echo ($x + $y); // 输出16 echo '<br>'; // 换行 echo ($x - $y); // 输出4 echo '<br>'; // 换行 echo ($x * $y); // 输出60 echo '<br>'; // 换行 echo ($x / $y); // 输出1.6666666666667 echo '<br>'; // 换行 echo ($x % $y); // 输出4 echo '<br>'; // 换行 echo -$x; ?>
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to implement multiplication in php. For more information, please follow other related articles on the PHP Chinese website!