settype
(PHP 4, PHP 5, PHP 7)
settype — 设置变量的类型
参数
- 
var
- 
      要转换的变量。 
- 
type
- 
      type的可能值为:- “boolean” (或为“bool”,从 PHP 4.2.0 起)
- “integer” (或为“int”,从 PHP 4.2.0 起)
- “float” (只在 PHP 4.2.0 之后可以使用,对于旧版本中使用的“double”现已停用)
- "string"
- "array"
- "object"
- “null” (从 PHP 4.2.0 起)
 
返回值
   成功时返回 TRUE, 或者在失败时返回 FALSE。
  
范例
Example #1 settype() 示例
<?php
$foo = "5bar"; // string
$bar = true;   // boolean
settype($foo, "integer"); // $foo 现在是 5   (integer)
settype($bar, "string");  // $bar 现在是 "1" (string)
?>
注释
Note:
Maximum value for "int" is
PHP_INT_MAX.