小编Tri*_*tan的帖子

如何使用ctype_alnum()允许下划线和短划线?

使用ctype_alnum()时,如何添加_-作为有效字符的例外?

我有以下代码:

if ( ctype_alnum ($username) ) {

  return TRUE;

} elseif (!ctype_alnum  ($username)) {

  $this->form_validation->set_message(
    '_check_username',
    'Invalid username! Alphanumerics only.'
  );

  return FALSE;
}
Run Code Online (Sandbox Code Playgroud)

php regex

9
推荐指数
2
解决办法
6127
查看次数

用PHP实现强密码

我试图检查,如果用户创建了包含符号(包括+, - ,=符号)OR/AND号的密码.我怎样才能做到这一点?

function check_password($str)
{

   if (!preg_match ("/[&@<>%\*\,\^!#$%().]/i", $str))

    {
        $this->form_validation->set_message('check_password', 'Your password should contain a number,letter,and special characters"');
        return FALSE;
    }
    else
    {
        return TRUE;
    }

} 
Run Code Online (Sandbox Code Playgroud)

谢谢.

php passwords codeigniter

5
推荐指数
2
解决办法
2635
查看次数

标签 统计

php ×2

codeigniter ×1

passwords ×1

regex ×1