博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php验证码数字_PHP:验证数值和数字
阅读量:2538 次
发布时间:2019-05-11

本文共 775 字,大约阅读时间需要 2 分钟。

php验证码数字

I've inherited a lot of code where the previous developer used PHP's is_numeric() and it's gotten them into trouble. There's a big difference between validating that a value is numeric and validating that a value is all digits. Here's how to validate the two:

我继承了很多代码,以前的开发人员在其中使用了PHP的is_numeric() ,这使他们陷入了麻烦。 验证值是数字与验证值是全数字之间有很大的区别。 验证这两种方法的方法如下:

/* numeric, decimal passes */function validate_numeric($variable) {	return is_numeric($variable);}/* digits only, no dots */function is_digits($element) {	return !preg_match ("/[^0-9]/", $element);}

A customer number, for example, should not have any decimal points but using is_numeric() would let a decimal value pass the test. Don't be this guy!

例如,客户编号不应包含任何小数点,但是使用is_numeric()可以让十进制值通过测试。 不要成为这个人!

翻译自:

php验证码数字

转载地址:http://mtpwd.baihongyu.com/

你可能感兴趣的文章
Azure Storage Blob文件重命名
查看>>
RxJava2.0 使用
查看>>
FreeImage的图像处理软件
查看>>
ASP.NET MVC开发必看系列
查看>>
点到平面的距离
查看>>
linux下安装FTP
查看>>
第四周编程总结
查看>>
《第12章 类的无参方法》
查看>>
经典机器学习算法系列7-svd
查看>>
mxnet系列 全连接层代码阅读
查看>>
0715
查看>>
Android开发进度06
查看>>
Beautiful Soup 中文文档
查看>>
USB各种模式 解释
查看>>
数据访问-----ADO.NET 小结和练习
查看>>
Linux lsof详解
查看>>
子组件给父组件传数据
查看>>
unix/linux下的共享内存、信号量、队列信息管理
查看>>
Hilbert先生旅馆的故事
查看>>
[家里蹲大学数学杂志]第394期分组求积分因子法
查看>>