>
Type casting in PHP works much as it does in C: the name of the desired type is written in parentheses before the variable which is to be cast.
1: $foo = 10; // $foo is an integer
2: $bar = (double) $foo; // $bar is a double
The casts allowed are:
• (int), (integer) - cast to integer
• (real), (double), (float) - cast to double
• (string) - cast to string
• (array) - cast to array
• (object) - cast to object
Note that tabs and spaces are allowed inside the parentheses, so the following are functionally
equivalent:
1: $foo = (int) $bar;
2: $foo = ( int ) $bar;