gettype() 函数用于获取变量的类型。 注意:不要使用 gettype() 来测试某种类型,因为其返回的字符串在未来的版本中可能需要改变。此外,由于包含了字符串的比较,它的运行也是较慢的。使用 is_* 函数代替。
版本要求:PHP 4, PHP 5, PHP 7 语法string gettype ( mixed $var ) 参数说明: 返回值返回字符串,可能值为: - boolean
- integer
- double
- string
- array
- object
- resource
- NULL
- unknown type
实例实例<?phpecho gettype(102) . PHP_EOL;echo gettype(true) . PHP_EOL;echo gettype(' ') . PHP_EOL;echo gettype(null) . PHP_EOL;echo gettype(array()) . PHP_EOL;echo gettype(new stdclass());?> 输出结果为: integerbooleanstringNULLarrayobject 下载地址: PHP get_resource_type() 函数 PHP import_request_variables() 函数 |