php检测数据类型

<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">检测数据类型即对数据类型进行检测,判断所检测类型是否属于检测类型,符合则返回真,否则返回假。检测数据类型定义如下:<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_bool


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为布尔类型,例,<font face="Times New Roman">is_bool(srue)  is_bool(false)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_string


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为字符串型,例,<font face="Times New Roman">is_string(<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">‘<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">string<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">’<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">)  is_string(1234)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_float/double


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为浮点型,例,<font face="Times New Roman">is_float(3.1415)  is_float(<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">‘<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">3.1415<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">’<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_integer/int


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为整型,例,<font face="Times New Roman">is_integer(34)  is_integer(<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">‘<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">34<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">’<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_null


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为空值,例,<font face="Times New Roman">is_null(null)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_array


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为数组,例,<font face="Times New Roman">is_array($arr)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_object


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为一个对象,例,<font face="Times New Roman">is_object($obj)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

is_numeric


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">是否为数字或由数字组成的字符串,例,<font face="Times New Roman">is_numeric(<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">‘<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">5<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">’<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">)  is_numeric(<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">‘<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">bcc110<span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">’<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">)<span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">示例


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'"><?PHP


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">$boo="1234567890";


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">if(is_numeric($boo))


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">echo "变量boo属由数字组成的字符串类型:".$boo;


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">else


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">echo"无法判断";


<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">?><span style="font-size: 10.5pt; font-family: '宋体'; mso-spacerun: 'yes'">

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...