Home > Article > Backend Development > PHP gets the type of variable
The content of this article is about the types of variables obtained by PHP. It has certain reference value. Now I share it with everyone. Friends in need can refer to it.
In PHP, you can pass gettype
Get the type of variable.
Example:
<?php $a=123;//整型 $b='123';//字符串型 $c=1.23;//浮点型 $d=true;//布尔型 $e=null;//NULL型 echo '$a是',gettype($a),'型','<br />'; echo '$b是',gettype($b),'型','<br />'; echo '$c是',gettype($c),'型','<br />'; echo '$d是',gettype($d),'型','<br />'; echo '$e是',gettype($e),'型','<br />'; ?>
The output result is:
$a是integer型 $b是string型 $c是double型 $d是boolean型 $e是NULL型
Related recommendations:
php to obtain excel table data
PHP Gets the column of the array where the specified value of a multi-dimensional array is located
The above is the detailed content of PHP gets the type of variable. For more information, please follow other related articles on the PHP Chinese website!