Common methods for determining variable types in PHP_PHP tutorial

WBOY
Release: 2016-07-21 15:19:16
Original
1078 people have browsed it

Now let us understand the specific usage

gettype()
gettype will return the following values ​​​​according to the parameter type
"boolean" (from PHP 4)
"integer"
"double" (returns "double" instead of "float" if float)
"string"
"array"
"object"
"resource" (since PHP 4)
"NULL" (from PHP 4)
"unknown type"

For example:
gettype('1'); returns string
while gettype(1); returns is integer


is_array()
The usage of is_array() is relatively simple
If the parameter is an array, it returns true, otherwise it returns false

The usage of several other functions and The return value is similar to is_array()
It should be noted here that is_numeric() is used to determine whether the variable is a number or a string of numbers
When the parameter of is_numeric() is a number or a string of numbers, it returns true Otherwise return false

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325319.htmlTechArticleNow let us understand the specific usage method gettype() gettype will return the following value "boolean" according to the parameter type ( Since PHP 4) "integer" "double" (if float then...
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