❮ PHP Variable Handling Reference
Convert variables to specific types:
<?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)
?>
Try it Yourself »
The settype() function converts a variable to a specific type.
settype(
variable,
type);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to convert |
type | Required. Specifies the type to convert variable to. The possible types are: boolean, bool, integer, int, float, double, string, array, object, null |
Return Value: | TRUE on success, FALSE on failure |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!