dongyong9224
2015-05-14 11:17
浏览 33
已采纳

UTF-8与php pdo和mysql - ctype php

How to use ctype_alpha with UTF-8

I have this code:

 if(empty($_POST) === false) {      

                if (isset($_POST['first_name']) && !empty ($_POST['first_name'])){
                    if (ctype_alpha($_POST['first_name']) === false) {
                    $errors[] = 'Please enter your First Name with only letters!';
                    }   
                }

so here I chech is everzthing fine if not I got error...

But If I use letters like ščćž - UTF-8 then I also get errors, so how I can sovle this problem becouse I need for first name to have onlz letters but I need to allow UTF-8 characters like ščćž

Please help!

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duandingqi9442 2015-05-14 11:21
    已采纳

    Make sure that EVERYTHING is in UTF8 NOBOM format. ALL php files must be saved in UTF8 NOBOM format. Adding just "charset=UTF-8" to html tag is not enough.

    Also you have to set UTF8 for database connection:

    mysql_query ('SET NAMES utf8');

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题