Home >Backend Development >PHP Tutorial >Which statement in php can output data of variable type
Use the gettype() function in PHP to determine the data type of a variable. This function returns a string containing the name of the variable type, including string, integer, float, boolean, array, object, resource, and NULL.
Output variable type data in PHP
Answer: gettype()
The gettype() function is used to determine the data type of a variable. It returns a string containing the name of the variable type.
Usage example:
<code class="php">$name = "John Doe"; echo gettype($name); // 输出:string</code>
Detailed description:
gettype() function works with any variable regardless of its type . It returns one of the following strings:
If the variable is undefined or null, gettype() will return "NULL".
Things to note:
The above is the detailed content of Which statement in php can output data of variable type. For more information, please follow other related articles on the PHP Chinese website!