选择语言 :

 Core_Valid::alpha_dash

Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.

boolean Core_Valid::alpha_dash( 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 alpha_dash($str, $utf8 = false)
{
    if ($utf8 === true)
    {
        $regex = '/^[-\pL\pN_]++$/uD';
    }
    else
    {
        $regex = '/^[-a-z0-9_]++$/iD';
    }

    return (bool)preg_match($regex, $str);
}