判断PHP数据类型
2016-01-29 23:45
531 查看
常用方式:is_int(), is_float()l, is_numeric(), is_array()...
另一种更快捷的方式:用 === 或 !== ,即全等和不全等运算符来判断。
I've found a faster way of determining an array. If you use is_array() millions of times, you will notice a *huge* difference. On my machine, this method takes about 1/4 the time of using is_array().
Cast the value to an array, then check (using ===) if it is identical to the original.
<?php
if ( (array) $unknown !== $unknown ) {
echo '$unknown is not an array';
} else {
echo '$unknown is an array';
}
?>
http://php.net/manual/zh/function.is-array.php
另一种更快捷的方式:用 === 或 !== ,即全等和不全等运算符来判断。
I've found a faster way of determining an array. If you use is_array() millions of times, you will notice a *huge* difference. On my machine, this method takes about 1/4 the time of using is_array().
Cast the value to an array, then check (using ===) if it is identical to the original.
<?php
if ( (array) $unknown !== $unknown ) {
echo '$unknown is not an array';
} else {
echo '$unknown is an array';
}
?>
http://php.net/manual/zh/function.is-array.php
相关文章推荐
- Heroku部署PHP应用
- 高级PHP应用程序漏洞审核技术
- php 整型 和 字符串相加
- Potplayer 全屏时 顶部有标题栏 显示文件名
- PHP和JSON
- PHP雪花背景验证码
- php一些常用函数的理解
- 申请TexturePacker免费注册码(TP:20C9A58A)
- 教研室 ftp 文件服务器使用教程
- 利用yum方式安装php7
- 使用PhpDocumentor生成文档
- FTP 服务器(一)之数据链路原理
- FTP 服务器(二)之vsftpd 服务器基础设定
- FTP 服务器(三)之客户端的图形接口 FTP 联机软件
- FTP 服务器(四)之实战搭建
- FTP 服务器(五)之客户端命令
- 使用php创建mysql的表格
- Windows上使用Vagrant打造Laravel Homestead可协同跨平台开发环境
- php分页
- php 多线程