gettype()

创建于 2024-12-03 / 52
字体: [默认] [大] [更大]

❮ PHP 变量处理参考

实例

返回不同变量的类型:

<?php
$a = 3;
echo gettype($a) . "<br>";

$b = 3.2;
echo gettype($b) . "<br>";

$c = "Hello";
echo gettype($c) . "<br>";

$d = array();
echo gettype($d) . "<br>";

$e = array("red", "green", "blue");
echo gettype($e) . "<br>";

$f = NULL;
echo gettype($f) . "<br>";

$g = false;
echo gettype($g) . "<br>";
?> 亲自试一试 »

定义和用法

gettype() 函数返回变量的类型。


语法

gettype(variable);

参数值

参数 描述
variable 必需。指定要检查的变量

技术细节

返回值: The type as a string. Can be one of the following values: "boolean", "integer", "double", "string", "array", "object", "resource", "NULL", "unknown type"
返回类型: String
PHP 版本: 4.0+
PHP 更新日志: PHP 7.2:关闭的资源现在返回为"resource (closed)"。 早些时候,返回值是"unknown type"未知类型。

❮ PHP 变量处理参考
0 人点赞过