Web hosting - PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Weak
Wednesday, October 31st, 2007PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Weak typing is a mixed blessing. It makes PHP very easy for beginners, but it means you often need to check that a variable contains the correct data type before using it. Doing calculations with PHP PHP is highly adept at working with numbers and can perform a wide variety of calculations, from simple arithmetic to complex math. This reference section covers only the standard arithmetic operators. See www.php.net/manual/en/ref.math.php for details of the mathematical functions and constants supported by PHP. Arithmetic operators The standard arithmetic operators all work the way you would expect, although some of them look slightly different from those you learned at school. For instance, an asterisk (*) is used as the multiplication sign, and a forward slash (/) is used to indicate division. Table 3-1 shows examples of how the standard arithmetic operators work. To demonstrate their effect, the following variables have been set: $x = 20; $y = 10; $z = 4.5; Table 3-1. Arithmetic operators in PHP Operation Operator Example Result Addition + $x + $y 30 Subtraction -$x - $y 10 Multiplication * $x * $y 200 Division / $x / $y 2 Modulo division % $x % $z 2 Increment (adds 1) ++ $x++ 21 Decrement (subtracts 1) $y-9 The modulo operator returns the remainder of a division, as follows: 26 % 5 // result is 1 26 % 27 // result is 26 10 % 2 // result is 0
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.