php method to add two numbers: 1. Use the " " addition operator, the syntax is "$num1 $num2"; 2. Use the "=" operator to add the variable on the left side of the operator The value of the expression on the right is assigned to the variable on the left, with the syntax "$num1 = $num2".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php implements two Number addition
#1. Use the " " addition operator
The " " operator is used for addition calculations.
Example:
<?php $a = -100; $b = 70; echo '$a + $b = '.($a + $b); ?>
2. Use the "=" operator
"=" plus equals assignment Operator, you can assign the value of the variable on the left side of the operator plus the expression on the right side to the variable on the left
Example:
<?php header("Content-type:text/html;charset=utf-8"); $a = 100; $b = 70; echo '$a += $b 的值为:'.($a += $b); ?>
Recommended study: " PHP video tutorial》
The above is the detailed content of How to add two numbers in php. For more information, please follow other related articles on the PHP Chinese website!