Chapter 5 . (Unlimited web hosting) Syntax and Variables 73 memory
Friday, November 30th, 2007Chapter 5 . Syntax and Variables 73 memory use and functionality were often agonizing. The PHP designers made what we think is a good decision to simplify this by having only two numerical types, corresponding to the largest of the integral and floating-point types in C. Integers Integers are the simplest type they correspond to simple whole numbers, both positive and negative. Integers can be assigned to variables, or they can be used in expressions, like so: $int_var = 12345; $another_int = -12345 + 12345; // will equal zero Read formats Integers can actually be read in three formats, which correspond to bases: decimal (base 10), octal (base
, and hexadecimal (base 16). Decimal format is the default, octal integers are specified with a leading 0, and hexadecimals have a leading 0x. Any of the formats can be preceded by a - sign to make the integer negative. For example: $integer_10 = 1000; $integer_8 = -01000; $integer_16 = 0×1000; print( integer_10: $integer_10
); print( integer_8: $integer_8
); print( integer_16: $integer_16
); yields the browser output: integer_10: 1000 integer_8: -512 integer_16: 4096 Note that the read format affects only how the integer is converted as it is read the value stored in $integer_8 does not remember that it was originally written in base 8. Internally, of course, these numbers are represented in binary format; we see them in their base 10 conversion in the preceding output because that is the default for printing and incorporating int variables into strings. Range How big (or small) can integers get? Because PHP integers correspond to the C long type, which in turn depends on the word-size of your machine, this is difficult to answer definitively. For most common platforms, however, the largest integer is 231 1 (or 2,147,483,647), and the smallest (most negative) integer is (231 1) (or 2,147,483,647). As far as we know, there is no PHP constant (like MAXINT in C) that will tell you the largest integer on your implementation. If you really need integers even larger or smaller than the preceding, PHP does have some arbitrary-precision functions see the BC section of the Mathematics chapter (Chapter 27). Doubles Doubles are floating-point numbers, such as: $first_double = 123.456; $second_double = 0.456 $even_double = 2.0;
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.