php判断变量类型常用方法_php技巧

WBOY
Release: 2016-05-17 09:11:38
Original
1158 people have browsed it

现在让我们了解下具体的使用方法

gettype()
gettype 会根据 参数类型返回下列值
“boolean”(从 PHP 4 起)
“integer”
“double”(如果是 float 则返回“double”,而不是“float”)
“string”
“array”
“object”
“resource”(从 PHP 4 起)
“NULL”(从 PHP 4 起)
“unknown type”

例如:
gettype('1');返回的是string
而gettype(1);返回的是integer


is_array()
is_array()的用法相对简单
如果参数是数组返回 true 否则返回 false

其他几个函数的用法和返回值与is_array()类似
这里需要注意的是 is_numeric()是用来判断 变量是否是数字或者数字符串的
当is_numeric() 的参数是数字或者数字字符串的时候 返回true 否则返 false

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