Add description of typecasting

This commit is contained in:
Malcolm Fell 2013-06-28 08:57:25 +12:00
parent 34852cc8be
commit c3cc11f2a8

View File

@ -144,7 +144,11 @@ echo $string + $string; // Also outputs 2 because the + operator converts the st
$string = 'one'; $string = 'one';
echo $string + $string; // Outputs 0 because the + operator cannot cast the string 'one' to a number echo $string + $string; // Outputs 0 because the + operator cannot cast the string 'one' to a number
```
Type casting can be used to treat a variable as another type temporarily by using cast operators in parentheses.
```php
$boolean = (boolean) $integer; // $boolean is true $boolean = (boolean) $integer; // $boolean is true
$zero = 0; $zero = 0;