PHP 中可用于输出变量类型的语句为:使用 gettype() 函数。
PHP 中输出变量类型的语句
以下 PHP 语句可以输出变量类型:
gettype()
使用 gettype() 函数
gettype() 函数返回一个字符串,表示变量的类型。该字符串包含以下类型之一:
立即学习“PHP免费学习笔记(深入)”;
示例
以下示例演示如何使用 gettype() 函数输出变量类型:
$x = 10; $y = "Hello"; $z = true; echo "Type of \$x: " . gettype($x) . "<br>"; echo "Type of \$y: " . gettype($y) . "<br>"; echo "Type of \$z: " . gettype($z) . "<br>";
输出:
Type of $x: integer<br> Type of $y: string<br> Type of $z: boolean<br>
以上就是php中哪个语句可以输出变量类型的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号