The prototype follows:
string sprintf(string format [, mixed arguments])
An example follows:
$cost = sprintf("$%.2f", 43.2); // $cost = $43.20
PHP??™s Supported Datatypes
A datatype is the generic name assigned to any data sharing a common set of characteristics.
Common datatypes include Boolean, integer, float, string, and array. PHP has
long offered a rich set of datatypes, and in this section you??™ll learn about them.
Scalar Datatypes
Scalar datatypes are capable of containing a single item of information. Several
datatypes fall under this category, including Boolean, integer, float, and string.
Boolean
The Boolean datatype is named after George Boole (1815??“1864), a mathematician
who is considered to be one of the founding fathers of information theory. A Boolean
variable represents truth, supporting only two values: TRUE and FALSE (case insensitive).
Alternatively, you can use zero to represent FALSE, and any nonzero value to represent
TRUE. A few examples follow:
$alive = false; // $alive is false.
$alive = 1; // $alive is true.
$alive = -1; // $alive is true.
$alive = 5; // $alive is true.
$alive = 0; // $alive is false.
Integer
An integer is representative of any whole number or, in other words, a number that
does not contain fractional parts. PHP supports integer values represented in base 10
(decimal), base 8 (octal), and base 16 (hexadecimal) numbering systems, although
66 CHAPTER 3 ?– PHP B ASICS
it??™s likely you??™ll only be concerned with the first of those systems.
Pages:
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150