Home  >  Article  >  Backend Development  >  PHP gets the type of variable

PHP gets the type of variable

不言
不言Original
2018-04-24 09:09:442792browse

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 gettypeGet the type of variable.

Example:

<?php
$a=123;//整型
$b=&#39;123&#39;;//字符串型
$c=1.23;//浮点型
$d=true;//布尔型
$e=null;//NULL型
echo &#39;$a是&#39;,gettype($a),&#39;型&#39;,&#39;<br />&#39;;
echo &#39;$b是&#39;,gettype($b),&#39;型&#39;,&#39;<br />&#39;;
echo &#39;$c是&#39;,gettype($c),&#39;型&#39;,&#39;<br />&#39;;
echo &#39;$d是&#39;,gettype($d),&#39;型&#39;,&#39;<br />&#39;;
echo &#39;$e是&#39;,gettype($e),&#39;型&#39;,&#39;<br />&#39;;
?>

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn