微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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'">

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐