网站首页 > 基础教程 正文
?????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-12 Linux库函数调用工具—ltrace命令
- 2024-10-12 C/C++恶意代码盘点(二):后门丨文件监控丨自删除功能
- 2024-10-12 C语言文件的随机读写、块读写、行、字符读写以及格式化输入输出
- 2024-10-12 C/C++恶意代码盘点(一):进程遍历丨木马病毒丨密码记录
- 2024-10-12 C/C++连接MySql数据库使用总结 c++连接数据库sqlserver
- 2024-10-12 MySQL:字符集问题 mysql字符集设置命令
- 2024-10-12 CAD常用语言函数 cad常用语言函数有哪些
- 2024-10-12 PHP压缩ZIP中文注释乱码问题解决办法
- 2024-10-12 Android Dalvik 使用详解 android dac
- 2024-10-12 C++|整型的最值、上溢、下溢、截断、类型提升和转换
- 最近发表
- 标签列表
-
- gitpush (61)
- pythonif (68)
- location.href (57)
- tail-f (57)
- pythonifelse (59)
- deletesql (62)
- c++模板 (62)
- css3动画 (57)
- c#event (59)
- linuxgzip (68)
- 字符串连接 (73)
- nginx配置文件详解 (61)
- html标签 (69)
- c++初始化列表 (64)
- exec命令 (59)
- canvasfilltext (58)
- mysqlinnodbmyisam区别 (63)
- arraylistadd (66)
- node教程 (59)
- console.table (62)
- c++time_t (58)
- phpcookie (58)
- mysqldatesub函数 (63)
- window10java环境变量设置 (66)
- c++虚函数和纯虚函数的区别 (66)