header("Content-type:text/html;charset=utf-8");
$a = 10;
$b = '60';
echo "$a+$b=".$ a+$b."
";
echo "$a-$b=".$a-$b."
";
echo "$a$b=". $a$b."
";
echo "$a/$b=".$a/$b."
";
?>
The value output by the final web page is as follows:
70
-50
10*60=600
10/60=0.16666666666667
How did you get these values?
header("Content-type:text/html;charset=utf-8");
$a = 10;
$b = '60';
echo "$a+$b=".$ a+$b."
";
echo "$a-$b=".$a-$b."
";
echo "$a$b=". $a$b."
";
echo "$a/$b=".$a/$b."
";
?>
The value output by the final web page is as follows:
70
-50
10*60=600
10/60=0.16666666666667
How did you get these values?
echo "$a+$b=".$a+$b."
";Execution result (+-. is the execution order of the same level from left to right)
<code>"$a+$b=" => '10+60=' "$a+$b=".$a => '10+60=10' ("$a+$b=".$a) + $b => intval('10+60=10') + intval($b) => 10+60 =>70</code>
Click to view PHP operator precedence
$a is an integer, which is stored as long in php. $b is a string, which is forced to be converted to an integer when performing arithmetic operations. The decimal obtained by the division operation is stored as a double, and the rest is mathematical operations
Basic operations: addition, subtraction, multiplication and division
Here the string is automatically converted to an integer to participate in the operation