网站首页 > 开源技术 正文
?????utf-8 gb2312 gbk?????г????в??????Сд,???Сд
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
???iconv?????????????
iconv ( string in_charset, string out_charset, string str )
?磺iconv("GB2312","UTF-8",$text);
???:???????????????out_charset???,????????iconv()????,???????????????????(????????????????)
??:imagettftext()????????utf-8?????
header("content-type:text/html; charset=utf-8");
?????????mysql_query("SET NAMES UTF8")
<?php
$conn=mysql_connect("localhost","root","111") or dir("?????????????".mysql_error()); //??????????????
mysql_select_db("db_database20",$conn) or die("????????????".mysql_error()); //????db_database18
mysql_query("set names utf8"); //??????????????
?>
????????????????????????
string mb_substr ( string str, int start [, int length [, string encoding]] )
???????????????????У??????
CREATE TABLE [IF NOT EXISTS] ?????? type=myisam default character set gbk collate gbk_chinese_ci;
CREATE TABLE [IF NOT EXISTS] ?????? type=myisam default character set utf8 collate utf8_general_ci;
???????????
??????????????????????Щ?????????????????Щ????????????
????? PHP ??????????????????????????
??????????????? gbk,utf8,gb2312
mb_strlen () ????????? strlen() ????????????
mb_strstr() ????????? strstr() ????????????β?????
mb_strpos() ????????? strpos() ??????????????
mb_substr() ????????? substr() ?????????????
mb_substr_count() ???????? substr_str() ?????????????????
iconv_strlen() ????????? strlen() ????????????
iconv_strpos() ????????? strpos() ??????????????
iconv_substr() ????????? substr() ????????????β?????
iconv_strrpos()????????? substr() ????????????????????????????λ??
?????ο???? ?????????????????|??????????
?????????????????|iconv
?????
<?php
setlocale(LC_ALL, 'en_US'); //???????????
echo strftime("%A %e %B %Y", time()); //?????????
echo "<br>";
setlocale(LC_ALL, 'chs'); //?????????
$dates=strftime("%A %e %B %Y", time()); //?????????
echo iconv("gb2312","utf-8",$dates); //??????????????????????????
?>
???:
???????(??????????????)?????????(?????????????)??????,????????????;
???±????????????:ANSI,??????????????,?????????ü??±???????;
window???±?????????????utf-8????????????BOM?;??utf-8?????????BOM?????????????????????????????????????utf-8????
????????к????????BOM??????????Щ??????????BOM???????PHP????????BOM?????????ü??±???utf-8???????о????????????
?????????BOM?
??? PHP|???|???|?????????BOM????
????????????NotePad++
phpDesigner8????? ?????php???????Bom?,????"???|???????|??BOM????"???,??????????,???????BOM????
??????utf-8???,????????????.
1.????????????????utf-8??BOM
???±?,???????????????"????"?utf-8
editPlus,????????"encoding"?utf-8
Notepadd++,??ctrl+A???????????????????Encoding-->Convert to UTF-8 without BOM
UEStudio??????????"???"?utf-8??BOM???????????????????
2.??PHP????<?php ?>??????????? header('Content-type : text/html; Charset=UTF-8'); ???????????utf-8
??html???(<head>??</head>???)д??<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />?????????????utf-8
3.PHP????????????????????????sql??????????′????????????????utf-8
???·?????????????? $myqli ?? $pdo ???????mysqli??pdo?????????
mysql_query('SET NAMES utf8'); // mysql ???
mysqli_query('SET NAMES utf8'); // mysqli ???
$mysqli->query('SET NAMES utf8'); // mysqli ???
$pdo->exec('SET NAMES utf8'); // PDO ???
4.????????????????????????utf8,?????У??(callate)?????utf8_general_ci,???MySQL??????utf8??????utf-8
IF NOT EXISTS `name`(
....????....
)ENGINE InnoDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
?????????,?????????????????????????.
猜你喜欢
- 2024-10-13 浅谈三种API设计风格RPC、REST、GraphQL
- 2024-10-13 7款主流sql工具大盘点!(好用的sql工具)
- 2024-07-06 Linux中Apache(httpd)配置反向代理二级域名
- 2024-07-06 没有个人网站都不好意思说自己是设计师,你还没有个人网站快来看
- 2024-07-06 「Stimulsoft Reports PHP教程」使用SQL数据源
- 2024-07-06 推荐一下自用的软件(PHP)(免费php软件)
- 2024-07-06 创建属于自己的矢量图图片(创建属性的三种方法)
- 2024-07-06 设计师必备的网站收集(设计师常用的网站)
- 2024-07-06 phpMyAdmin 4.9.1发布 基于Web的MySQL管理工具
- 2024-07-06 自制天线的好帮手——天线计算器(天线制作方法)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- jdk (81)
- putty (66)
- rufus (78)
- 内网穿透 (89)
- okhttp (70)
- powertoys (74)
- windowsterminal (81)
- netcat (65)
- ghostscript (65)
- veracrypt (65)
- asp.netcore (70)
- wrk (67)
- aspose.words (80)
- itk (80)
- ajaxfileupload.js (66)
- sqlhelper (67)
- express.js (67)
- phpmailer (67)
- xjar (70)
- redisclient (78)
- wakeonlan (66)
- tinygo (85)
- startbbs (72)
- webftp (82)
- vsvim (79)
本文暂时没有评论,来添加一个吧(●'◡'●)