如何检查PHP变量是否包含非数字? [英] how to check if PHP variable contains non-numbers?

查看:118
本文介绍了如何检查PHP变量是否包含非数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想知道检查PHP变量中是否有非数字的方法,以及它是否还能检测字符之间的空格?需要确保没有任何奇怪的东西放入我的表单字段中.预先感谢.

I just want to know the method to check a PHP variable for any non-numbers and if it also detects spaces between characters? Need to make sure nothing weird gets put into my form fields. Thanks in advance.

推荐答案

如果您的意思是只希望一个值包含数字,则可以使用

If you mean that you only want a value to contain digits then you can use ctype_digit().

这篇关于如何检查PHP变量是否包含非数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆