php mysql ²ÉÓà utf 8 µÄÅäÖÃ
1¡¢ÔÚÅäÖÃmysqlʵÀýµÄÓïÑÔÑ¡Ïîʱ£¬Ñ¡Ôñutf-8
2¡¢ÔÚhtml,phpÒ³ÃæÖÐ ¼ÓÉÏ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />£¬Èç¹û²»ÐÐÔÙÔÚ phpÎļþ Æðʼ´¦¼Ó header("Content-Type:text/html;charset=utf-8");
3¡¢ÔÚphpÖÐ×öÊý¾Ý¿âÁ¬½Óʱ£¬ÎÒÓõÄʱpdoµÄÐÎʽ£¬ËùÒÔÔÚ»ñµÃÒ»¸ö Connectionºó£¬½ô½Ó×ÅÖ´ÐÐ $conn->query("set names utf8");
ÏÂÃæÊÇÎҵĻñÈ¡Êý¾Ý¿âÁ¬½ÓµÄ·½·¨:
public static function getConnection(){
$conn = new PDO(self::dsn, self::user, self::password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->query("set names utf8");
return $conn;
}
4¡¢Èç¹ûʹÓÃÃüÁîÐÐÈ¥Á¬½ÓÊý¾Ý¿â×öһЩ²éѯµÄ»°£¬ÇëÏÈÔÚ²éѯǰִÐÐ show variables like '%char%'; ¿´¿´Êä³öµÄÊDz»ÊÇÈçÏÂÃæ:
character_set_client gbk
character_set_connection gbk
character_set_database utf8
character_set_filesystem binary
character_set_results gbk
character_set_server utf8
character_set_system utf8
Èç¹û²»ÊÇ£¬ÇëÏÈÖ´ÐÐ set names gbk;
È»ºóÔÙ×öÒ»°ãµÄ²éѯ¡£
Ïà¹ØÎĵµ£º
1£º apache·þÎñÆ÷°²×°.apache_2.0.59-win32-x86-no_ssl.msi¡£
ÐÞ¸Äconf\httpd.confÖеÄÎļþ£¬ÐÞ¸ÄλÖÃΪ£º
DocumentRoot "c:/webpage" ÉèÖÃÐéÄâĿ¼ c:/webpage.
DirectoryIndex index.html index.html.var index.php
==ʹapache·þÎñÆ÷ʶ±ðphpµÄÀ©Õ¹Ãû¡£
ÔÚ<Directory "c:/pr ......
´ÓHTMLÎļþÖжÁÈ¡Ö¸¶¨×Ö·û´®
ÔÌùµØÖ·£ºhttp://topic.csdn.net/u/20100322/10/d7401c38-10b7-4231-a323-454caf946fa6.html
2.
<a title="1" href="sdfds" m ......
Ê×ÏÈ˵×î¸ù±¾µÄ½â¾ö·½·¨£º
ÊÖ »ú·ÃÎÊʱ£¬»á¸½´ø·¢ËÍuser-agentÐÅÏ¢£¬Õâ¸öÐÅÏ¢ÀïÃæ»áÓÐÊÖ»úºÅÂëÐÅÏ¢£¬ÄÇôÈç¹ûÄÜÈ¡µÃÊÖ»úºÅÂ룬Ôò¿ÉÒԿ϶¨ÊÇͨ¹ýÊÖ»úwap·ÃÎʵġ£µ«ÊÇÄ¿Ç°ÖÐ ¹úÒƶ¯ÒѾÆÁ±ÎÁËuser-agentÐÅÏ¢£¬ËùÒÔ»ñÈ¡²»µ½ÊÖ»úºÅÂë¡£ÓйØϵµÄÅóÓÑ¿ÉÒÔÁªÏµÒƶ¯¹«Ë¾£¬°ÑwapÍøÕ¾·þÎñÆ÷µÄipÌá½»¸øÖйúÒƶ¯£¬¼ÓÈë°×Ãûµ¥ ºó¼´¿ÉÈ¡µ ......
<?php
//ÉùÃ÷Êý×é±äÁ¿
$arr = array(val1 =>'ÕÅÈý',val2 => 'ÀîËÄ',val3 => 'ÍõÎå',val4 => 'ÀîÃ÷',val5 => 'ÖÜÑàÄÝ');
//foreachÑ»·±éÀúÊý×é
foreach($arr as $key => $value){
//×¢Òâ“$value”ºó±ØÐëÒªÒ»¸ö¿Õ¸ñ£¬·ñÔòÊä ......
<?php
//»ñµÃϵͳʱ¼äº¯Êý(×¢Òâ²ÎÊýÖдóдY´ú±íÍêÕûÄê·Ý£¬Ð¡Ð´y´ú±íÄê·Ý¼òд)
$sum = date("Y-m-d");
$sum1 = date("y-m-d");
echo "$sum<br/>";
echo "$sum1<br/>";
//md5¼ÓÃܺ¯Êý
$pass = md5("ÕÅÈý");
......