Summary of common data types in PHP
This article mainly explains "a summary of common data types in PHP", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let Xiaobian take you to learn "Summary of common data types in PHP"!
PHP data types
PHP supports eight primitive types.
Four scalar types:
string (string)
integer (integer)
float (also double)
boolean
Two composite types:
array (array)
object
Two special types:
resource
NULL
View variable types
The gettype() function allows you to easily check the type of a variable:
The copy code is as follows:
(PS: T good PHP Q button: 276167802, verification: csl)
prompt
For historical reasons, gettype() returns double instead of float for float data.
If you want to see the value and type of an expression, use the var_dump() function.
Determine variable type
If you want to determine the next logical action by judging the variable type, don't use gettype(), but use the is_type series function:
The copy code is as follows:
At this point, I believe that everyone has a deeper understanding of the "summary of common data types in PHP", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!