Prev | Current Page 139 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Several examples
follow:
42 // decimal
-678900 // decimal
0755 // octal
0xC4E // hexadecimal
The maximum supported integer size is platform-dependent, although this is typically
positive or negative 231 for PHP version 5 and earlier. PHP 6 introduced a 64-bit
integer value, meaning PHP will support integer values up to positive or negative 263
in size.
Float
Floating-point numbers, also referred to as floats, doubles, or real numbers, allow you
to specify numbers that contain fractional parts. Floats are used to represent monetary
values, weights, distances, and a whole host of other representations in which a simple
integer value won??™t suffice. PHP??™s floats can be specified in a variety of ways, each of
which is exemplified here:
4.5678
4.0
8.7e4
1.23E+11
String
Simply put, a string is a sequence of characters treated as a contiguous group. Strings
are delimited by single or double quotes, although PHP also supports another delimitation
methodology, which is introduced in the later section ???String Interpolation.???
The following are all examples of valid strings:
"PHP is a great language"
"whoop-de-do"
'*9subway\n'
"123$%^789"
Historically, PHP treated strings in the same fashion as arrays (see the next section,
???Compound Datatypes,??? for more information about arrays), allowing for specific characters
to be accessed via array offset notation.


Pages:
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151