Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15838
  • 博文数量: 5
  • 博客积分: 92
  • 博客等级: 民兵
  • 技术积分: 65
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-17 00:45
文章分类

全部博文(5)

文章存档

2011年(5)

我的朋友

分类: 系统运维

2011-08-07 21:00:57

gettype

(PHP 4, PHP 5)

gettype — 获取变量的类型

描述
string gettype (  $var )

返回PHP变量$var的类型。mixed代表该变量可以是任意类型。

警告

千万不要用 gettype() 测试变量类型,因为后续版本会影响到函数返回值。此外,此函数的执行速度太慢了。

可以使用 is_* 函数代替参函数。

参数

var

确定类型的变量

返回值

返回字符串的可能取值:

  • ""
  • ""
  • "" (由于历史的原因,float类型返回值是"double")
  • ""
  • ""
  • ""
  • ""
  • ""
  • "unknown type"

Examples

Example #1 gettype() example


$data 
= array(11.NULL, new stdClass'foo');

foreach (
$data as $value) {
    echo 
gettype($value), "\n";
}

?>

The above example will output something similar to:

integer double NULL object string

 See Also

  •  - Set the type of a variable
  •  - Returns the name of the class of an object
  •  - Finds whether a variable is an array
  •  - Finds out whether a variable is a boolean
  •  - Finds whether the type of a variable is float
  •  - Find whether the type of a variable is integer
  •  - Finds whether a variable is NULL
  •  - Finds whether a variable is a number or a numeric string
  •  - Finds whether a variable is an object
  •  - Finds whether a variable is a resource
  •  - Finds whether a variable is a scalar
  •  - Find whether the type of a variable is string
  •  - Return TRUE if the given function has been defined
  •  - Checks if the class method exists


阅读(1948) | 评论(0) | 转发(0) |
0

上一篇:PHP中的字符串

下一篇:PHP函数_settype()

给主人留下些什么吧!~~