PHP gets the type of variable

不言
Release: 2023-03-24 18:22:02
Original
2805 people have browsed it

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;;
?>
Copy after login

The output result is:

$a是integer型
$b是string型
$c是double型
$d是boolean型
$e是NULL型
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template