English 中文(简体)
当我把我的我的我的我的我的SQL数据库改为UTF-8编码时,我应当更新我的PHP。
原标题:What should I update in my PHP setup when I change my MySQL databases to UTF-8 encoding?

目前,我开设了一个有关PHP 5和MySQL骨干的网站。 MySQL数据库使用cp1252 West Europe ( latin1 ) encoding,和latin1_swedish_cp

我将MySQL数据库改为UTF-8 encoding and utf8_general_ci。 我无需帮助将MySQL内部的内容转换为Im处理,因为这一处理涉及并更新了现场的所有内容。 Assume I m在这次谈话中这样做是正确的(尽管我可能不会这样做)。

我知道在php.ini有这样的环境:default_charset,即违约至iso-8859-1。 我也知道,如果我处理含有多维的UTF-8特性的插座,那么许多PHP的操纵功能,如<代码>strlen(<>>>>>>>,以及reg,就不会正确发挥作用,我认识到,UTF-8的特性并非都是如此。

www.un.org/Depts/DGACM/index_spanish.htm 在我网络应用中,我需要做些什么来应对来自我数据库的八国联合部队? 是什么?

最佳回答

您将必须建立与以下各方面的联系:

mysql_query("SET NAMES  utf8 ");

And then replace your "regular" string functions with those from the mbstring module : http://php.net/manual/en/book.mbstring.php like mb_strlen, mb_substr, etc.

并且根据需要具体指明UTF-8编码,例如,在主管部门的职能中:

echo htmlentities($str, ENT_QUOTES, "UTF-8");
问题回答

See this function。

此外,你应当把你的所有档案都保存在utf-8上(最好没有BOM)。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签