选择语言 :

 Core_Valid::digit

Checks whether a string consists of digits only (no dots or dashes).

boolean Core_Valid::digit( string $str [, boolean $utf8 = bool false ] )

参数列表

参数 类型 描述 默认值
$str string Input string
$utf8 boolean Trigger UTF-8 compatibility bool false
返回值
  • boolean
File: ./core/classes/valid.class.php
public static function digit($str, $utf8 = false)
{
    if ($utf8 === true)
    {
        return (bool)preg_match('/^\pN++$/uD', $str);
    }
    else
    {
        return (is_int($str) && $str >= 0) || ctype_digit($str);
    }
}