PHPÖÐÎÄÂÒÂë½â¾ö°ì·¨
Ò»£® Ê×ÏÈÊÇPHPÍøÒ³µÄ±àÂë
1. phpÎļþ±¾ÉíµÄ±àÂëÓëÍøÒ³µÄ±àÂëӦƥÅä
a. Èç¹ûÓûʹÓÃgb2312±àÂ룬ÄÇôphpÒªÊä³öÍ·£ºheader(“Content-Type: text/html; charset=gb2312")£¬¾²Ì¬Ò³ÃæÌí¼Ó<meta http-equiv="Content-Type" content="text/html; charset=gb2312">£¬ËùÓÐÎļþµÄ±àÂë¸ñʽΪANSI£¬¿ÉÓüÇʱ¾´ò¿ª£¬Áí´æΪѡÔñ±àÂëΪANSI£¬¸²¸ÇÔ´Îļþ¡£
b. Èç¹ûÓûʹÓÃutf-8±àÂ룬ÄÇôphpÒªÊä³öÍ·£ºheader(“Content-Type: text/html; charset=utf-8")£¬¾²Ì¬Ò³ÃæÌí¼Ó<meta http-equiv="Content-Type" content="text/html; charset=utf-8">£¬ËùÓÐÎļþµÄ±àÂë¸ñʽΪutf-8¡£±£´æΪutf-8¿ÉÄÜ»áÓеãÂé·³£¬Ò»°ãutf-8Îļþ¿ªÍ·»áÓÐBOM£¬Èç¹ûʹÓà session¾Í»á³öÎÊÌ⣬¿ÉÓÃeditplusÀ´±£´æ£¬ÔÚeditplusÖУ¬¹¤¾ß->²ÎÊýÑ¡Ôñ->Îļþ->UTF-8Ç©Ãû£¬Ñ¡Ôñ×Ü ÊÇɾ³ý£¬ÔÙ±£´æ¾Í¿ÉÒÔÈ¥µôBOMÐÅÏ¢ÁË¡£
2. php±¾Éí²»ÊÇUnicodeµÄ£¬ËùÓÐsubstrÖ®ÀàµÄº¯ÊýµÃ¸Ä³Émb_substr£¨ÐèҪװmbstringÀ©Õ¹£©£»»òÕßÓÃiconvתÂë¡£
¶þ£® PHPÓëMysqlµÄÊý¾Ý½»»¥
PHPÓëÊý¾Ý¿âµÄ±àÂëÓ¦Ò»ÖÂ
1. ÐÞ¸ÄmysqlÅäÖÃÎļþmy.ini»òmy.cnf£¬mysql×îºÃÓÃutf8±àÂë
[mysql]
default-character-set=utf8
[mysqld]
default-character-set=utf8
default-storage-engine=MyISAM
ÔÚ[mysqld]ϼÓÈë:
default-collation=utf8_bin
init_connect='SET NAMES utf8'
2. ÔÚÐèÒª×öÊý¾Ý¿â²Ù×÷µÄphp³ÌÐòÇ°¼Ómysql_query("set names '±àÂë'");£¬±àÂëºÍphp±àÂëÒ»Ö£¬Èç¹ûphp±àÂëÊÇgb2312ÄÇmysql±àÂë¾ÍÊÇgb2312£¬Èç¹ûÊÇutf-8ÄÇmysql±àÂë¾ÍÊÇ utf8£¬ÕâÑù²åÈë»ò¼ìË÷Êý¾Ýʱ¾Í²»»á³öÏÖÂÒÂëÁË
Èý£® PHPÓë²Ù×÷ϵͳÏà¹Ø
WindowsºÍLinuxµÄ±àÂëÊDz»Ò»ÑùµÄ£¬ÔÚWindows»·¾³Ï£¬µ÷ÓÃPHPµÄº¯Êýʱ²ÎÊýÈç¹ûÊÇutf-8±àÂë»á³öÏÖ´íÎ󣬱ÈÈç move_uploaded_file()¡¢filesize()¡¢readfile()µÈ£¬ÕâЩº¯ÊýÔÚ´¦ÀíÉÏ´«¡¢ÏÂÔØʱ¾³£»áÓõ½£¬µ÷ÓÃʱ¿ÉÄÜ»á³öÏÖÏ ÃæµÄ´íÎó:
Warning: move_uploaded_file()[function.move-uploaded-file]:failed to open stream:
Ïà¹ØÎĵµ£º
ÔÚÏßʵʱÁÄÌìϵͳ£¬Ò»Ö±ÊÇÒ»¸ö±È½ÏÂé·³µÄ¶«Î÷¡£
Ò»°ãʵÏÖÔÚÏßʵʱÁÄÌ죬ÊÇÀûÓÃJSÔÚ¿Í»§¶ËʹÓÃajaxÿ¸ôÒ»¶¨µÄʱ¼ä¾Í·µ»Ø·þÎñÆ÷ÇëÇóÊý¾Ý£¬Èç¹ûÓÐеÄÁÄÌìÐÅÏ¢ÔòÓÃJS³ÊÏÖ¸øÓû§
ÎÒÃDz»ËµÕâÑù×öµÄÀû±×£¬Ö±½ÓÇÐÈëÕýÌ⣬ÈçºÎÀ´ÊµÏÖ·þÎñÆ÷ÍƵÄÔÚÏßÁÄÌìϵͳ
Ê×ÏÈ£¬ÎÒÏÈÇë´ó¼Ò¿´Ò»¸öÀý×Ó
¸´ÖÆ´úÂë
<?php
while(true){
&n ......
²©¿Í£ºWordPress
WordPressÊÇʹÓÃPHP¿ª·¢µÄÖøÃû²©¿Íƽ̨£¬Ãâ·Ñ¿ªÔ´£¬¹¦ÄÜÇ¿´ó£¬²»½ö½öÓÃÓÚ²©¿Í´î½¨£¬»¹¿ÉÒԹ㷺ӦÓÃÓÚ¸÷ÀàÍøÂçÐÅÏ¢·¢²¼Æ½Ì¨¡£
ÂÛ̳£ºphpBB
phpBBÊÇÒ»Öֹ㷺Á÷ÐеĿªÔ´ÂÛ̳Èí¼þ£¬¾ßÓÐÒ×ÓÚʹÓõĹÜÀíÃæ°åºÍÓѺõÄÓû§°²×°½çÃ棬¿ÉÒÔÇáËɵØÔÚÊý·ÖÖÓÄÚ½¨Á¢ÆðÒ»¸öÂÛ̳£¬¹¦ÄÜÉϾßÓкܸߵĿÉÅäÖÃÐÔ£¬Äܹ»ÍêÈ«¶¨Ö ......
Í·²¿µ÷ÓÃ
<?
require('conn.php');
$sql1="select id from news";
$query1=mysql_query($sql1,$conn);
$sun_num=mysql_num_rows($query1);
$gs=20;
$page_num=ceil($sun_num/$gs);
include("../subpage.php");
//´«¹ýÀ´µÄÒ³Êý²ÎÊý
$PB_page=$_GET['PB_page'];
if ($PB_page==1 or empty($PB_page)){
$ ......