We'll start with the math operators, which are the most basic of all operators:
You can see them all at work in phpmath.php; here's the PHP: Example 2-1. Using the Math operators, phpmath.php<HTML> <BODY> <H1>The math operators</H1> <?php echo "5 + 2 = ", 5 + 2, "<BR>"; echo "5 - 2 = ", 5 - 2, "<BR>"; echo "5 * 2 = ", 5 * 2, "<BR>"; echo "5 / 2 = ", 5 / 2, "<BR>"; echo "5 % 2 = ", 5 % 2, "<BR>"; ?> </BODY> </HTML> The results, all as expected, appear in Figure 2-1. Figure 2-1. The math operators. |