PHPç½é¡µçç¼ç é®é¢
è°è°ApacheåPHPç½é¡µçç¼ç ãè¿æä¸ç¯å
³äºMySQLå符éçï¼http://potatows.eeie.cn/?p=39
è°å°Apacheçç¼ç æ们就è¦æ¶åå°3个ä¸è¥¿
httpæ è®°è¯è¨ä¸çæ ç¾
PHPä¸çheader("content-type:text/html; charset=xxx");å½æ°
Apacheé
ç½®æ件httpd.confä¸çAddDefaultCharset
ä¸ãæ ç¾
æ顺åºæ¥ï¼å
说è¿ä¸ªæ ç¾ï¼è¿ä¸ªæ ç¾æå¾å¤åè½çï¼å
·ä½è¯·ç¹è¿éã
æä»å¤©æ³è¯´åªæ¯ä¸é¢æå°çé£ç§å½¢å¼ã解éä¸ä¸ï¼æææ¯å¯¹è¿ä¸ªç½é¡µè¿è¡å£°æï¼è®©æµè§å¨å¯¹æ´ä¸ªé¡µé¢çå
容éç¨xxxç¼ç ï¼xxxå¯ä»¥ä¸ºGB2312ï¼GBKï¼UTF-8ï¼åMySQLä¸åï¼MySQLæ¯UTF8ï¼ççãå æ¤ï¼å¤§é¨å页é¢å¯ä»¥éç¨è¿ç§æ¹å¼æ¥åè¯æµè§å¨æ¾ç¤ºè¿ä¸ªé¡µé¢çæ¶åéç¨ä»ä¹ç¼ç ï¼è¿æ ·æä¸ä¼é æç¼ç é误è产çä¹±ç ãä½æ¯æçæ¶åæ们ä¼åç°æäºè¿å¥è¿æ¯ä¸è¡ï¼ä¸ç®¡xxxæ¯åªä¸ç§ï¼æµè§å¨éç¨çå§ç»é½æ¯ä¸ç§ç¼ç ï¼è¿ä¸ªæ
åµæåé¢ä¼è°å°ã
请注æï¼æ¯å±äºhtmlä¿¡æ¯çï¼ä»
ä»
æ¯ä¸ä¸ªå£°æï¼å®èµ·ä½ç¨è¡¨ææå¡å¨å·²ç»æHTMLä¿¡æ¯ä¼ å°äºæµè§å¨ã
äºãheader("content-type:text/html; charset=xxx");
è¿ä¸ªå½æ°header()çä½ç¨æ¯ææ¬å·éé¢çä¿¡æ¯åå°httpæ 头ãå
³äºæ¤å½æ°å
·ä½ç¨æ³è¯·ç¹å»è¿éã
å¦ææ¬å·éé¢çå
容为æä¸æ说é£æ ·ï¼é£ä½ç¨åæ ç¾åºæ¬ç¸åï¼å¤§å®¶å¯¹ç
§ç¬¬ä¸ä¸ªçåç°å符é½å·®ä¸å¤çãä½æ¯ä¸åçæ¯å¦ææè¿æ®µå½æ°ï¼æµè§å¨å°±ä¼æ°¸è¿éç¨ä½ æè¦æ±çxxxç¼ç ï¼ç»å¯¹ä¸ä¼ä¸å¬è¯ï¼å æ¤è¿ä¸ªå½æ°æ¯å¾æç¨çã为ä»ä¹ä¼è¿æ ·å¢ï¼é£å°±å¾è¯´è¯´HTTPSæ 头åHTMLä¿¡æ¯çå·®å«äºï¼
å¼ç¨:
httpsæ 头æ¯æå¡å¨ä»¥HTTPåè®®ä¼ éHTMLä¿¡æ¯å°æµè§å¨åæéåºçå串ã
å 为metaæ ç¾æ¯å±äºhtmlä¿¡æ¯çï¼æ以header()åéçå
容å
å°è¾¾æµè§å¨ï¼éä¿ç¹å°±æ¯header()çä¼å
级é«äºmetaï¼ä¸ç¥éå¯ä¸å¯ä»¥è¿æ ·è®²ï¼ãå å
¥ä¸ä¸ªphp页é¢æ¢æheader("content-type:text/html; charset=xxx")ï¼åæï¼æµè§å¨å°±åªè®¤åè
httpæ 头èä¸è®¤metaäºãå½ç¶è¿ä¸ªå½æ°åªè½å¨php页é¢å
使ç¨ã
åæ ·ä¹çæä¸ä¸ªé®é¢ï¼ä¸ºä»ä¹åè
å°±ç»å¯¹èµ·ä½ç¨ï¼èåè
ææ¶åå°±ä¸è¡å¢ï¼è¿å°±æ¯æ¥ä¸æ¥è¦è°çApacheçåå äºã
ä¸ãAddDefaultCharset
Apacheæ ¹ç®å½çconfæ件夹éï¼ææ´ä¸ªApacheçé
ç½®ææ¡£httpd.confãå
·ä½å¦ä½é
ç½®apache请ç¹å»è¿éï¼[url=thread-2674-1-1.html]windows[/url]ï¼[url=thread-1381-1-1.html]linux[/url]ï¼ã
ç¨ææ¬ç¼è¾å¨æå¼httpd.confï¼ç¬¬708è¡ï¼ä¸åçæ¬å¯è½ä¸åï¼æAddDefaultCharset xxxï¼xxx为ç¼ç å称ãè¿è¡ä»£ç çææï¼è®¾ç½®æ´ä¸ªæå¡å¨å
çç½é¡µæ件httpsæ 头éçå符éä¸ºä½ é»è®¤çxxxå符éãæè¿è¡ï¼å°±ç¸å½äºç»æ¯ä¸ªæ件é½å äºä¸è¡header("content-type:text/html; charset=xxx")ãè¿ä¸å°±æç½ä¸ºä»ä¹ææmeta设置äºæ¯utf-8ï¼å¯æµè§å¨å§ç»éç¨gb2312çåå ã
å¦æç½é¡µéæheader("content-type:text/html; charset=xxx")ï¼å°±æé»è®¤çå符éæ¹ä¸ºä½ 设置çå符éï¼æ以è¿ä¸ªå½æ°æ°¸è¿æç¨ãå¦ææAddDefaultCharset xxxåé¢å 个“#”ï¼æ³¨éæè¿å¥ï¼èä¸é¡µé¢éä¸å«header("content-type…")ï¼é£è¿ä¸ªæ¶å就轮å°metaæ ç¾èµ·ä½ç¨äºã
æ»ç»ï¼
æ¥ä¸ªæåº
header("content-type:text/html; charset=xxx")
AddDefaultCharset xxx
å¦æä½ æ¯webç¨åºåï¼ç»ä½ çæ¯ä¸ªé¡µé¢é½å 个header("content-type:text/html; charset=xxx")ï¼ä¿è¯å®å¨ä»»ä½æå¡å¨é½è½æ£ç¡®æ¾ç¤ºï¼å¯ç§»æ¤æ§å¼ºã
è³äºé£å¥AddDefaultCharset xxxï¼è¦ä¸è¦æ³¨éå°±ä»è
è§ä»äºãåæ£ææ¯æ³¨éæäºï¼ä¸è¿æå页åä¹è¦åheader()ï¼ä¾¿äºæ¾å°ä¸åçæå¡å¨ä¸è½æ£å¸¸æ¾ç¤ºã