PHP中用于输出变量类型的函数是gettype()。它接受一个变量作为参数,并返回一个字符串,表示变量的类型,如"string"、"integer"、"boolean"或"array"。

PHP中输出变量类型的语句
在PHP中,gettype() 函数用于输出变量的类型。
语法:
<code class="php">gettype($variable);</code>
参数:
立即学习“PHP免费学习笔记(深入)”;
-
$variable:要检查类型的变量
返回值:
一个字符串,表示变量的类型。常见类型包括:
stringintegerfloatbooleanarrayobjectNULL
示例:
<code class="php">$name = "John Doe"; $age = 30; $isMarried = true; echo gettype($name); //输出 "string" echo gettype($age); //输出 "integer" echo gettype($isMarried); //输出 "boolean"</code>











