类型强制转换
PHP 中的类型强制转换和 C 中的非常像:在要转换的变量之前加上用括号括起来的目标类型:
<?php $foo = 10; // $foo 为整型 $bar = (boolean) $foo; // $bar 为布尔型 ?>
允许的强制转换有:
- (int)或(integer) - 转换成整型
- (bool)或(boolean) - 转换成布尔型
- (float)或(double)或(real) - 转换成浮点型
- (string) - 转换成字符串
- (array) - 转换成数组
- (objec...