Variable handling 函数
PHP 手册

settype

(PHP 4, PHP 5)

settype设置变量的类型

描述

bool settype ( mixed $var , string $type )

将变量 var 的类型设置成 type

type 的可能值为:

如果成功则返回 TRUE,失败则返回 FALSE

Example #1 settype() 示例

<?php
$foo 
"5bar"// string
$bar true;   // boolean

settype($foo"integer"); // $foo 现在是 5   (integer)
settype($bar"string");  // $bar 现在是 "1" (string)
?>

参见 gettype()类型转换类型戏法


Variable handling 函数
PHP 手册