Php/func var settype
来自菜鸟教程
PHP settype()函数
例
将变量转换为特定类型:
<?php $a = "32"; // string settype($a, "integer"); // $a is now integer $b = 32; // integer settype($b, "string"); // $b is now string $c = true; // boolean settype($c, "integer"); // $c is now integer (1) ?>
定义和用法
settype()函数将变量转换为特定类型。
句法
settype(variable, type);
参数值
| 参数 | 描述 |
|---|---|
| variable | 需要。指定要转换的变量 |
| type | 需要。指定要转换的类型
variable to.可能的类型是:布尔值,布尔值,整数,整数,浮点数,双精度数,字符串,数组,对象,空值 |
技术细节
| 返回值: | 成功则为TRUE,失败则为FALSE |
| 返回类型: | 布尔型 |
| PHP版本: | 4.0+ |