PHP settype() 函数

PHP 可用的函数PHP 可用的函数

settype() 函数用于设置变量的类型。

PHP 版本要求: PHP 4, PHP 5, PHP 7

语法

bool settype ( mixed &$var , string $type )

参数说明:

  • $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。