字符类型检测

属性
命名空间 fize\security
类名 Ctype
方法:
方法名 说明
alnum() 判断是否全部为字母和(或)数字字符。
alpha() 判断字符串是否为全字母
cntrl() 判断是不是都是控制字符。
digit() 判断提供的字符串是不是纯数字。
graph() 做可打印字符串检测,空格除外
lower() 做小写字符检测
print() 做可打印字符检测
punct() 检测可打印的字符是不是不包含空白、数字和字母
space() 做空白字符检测
upper() 做大写字母检测
xdigit() 检测字符串是否只包含十六进制字符

方法

alnum()

判断是否全部为字母和(或)数字字符。

public static function alnum (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

alpha()

判断字符串是否为全字母

public static function alpha (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

cntrl()

判断是不是都是控制字符。

public static function cntrl (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串
控制字符就是例如:换行、缩进、空格。

digit()

判断提供的字符串是不是纯数字。

public static function digit (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串
注意传入的必须是 string 类型,传入 int 会导致判断错误。

graph()

做可打印字符串检测,空格除外

public static function graph (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

lower()

做小写字符检测

public static function lower (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

print()

做可打印字符检测

public static function print (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

punct()

检测可打印的字符是不是不包含空白、数字和字母

public static function punct (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

space()

做空白字符检测

public static function space (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

upper()

做大写字母检测

public static function upper (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串

xdigit()

检测字符串是否只包含十六进制字符

public static function xdigit (
    string $text
) : bool
参数:
名称 说明
text 待判断字符串