ÍêÃÀ½â¾öPHPÖÐÎÄÂÒÂëÎÊÌâ
Ò».Ê×ÏÈÊÇPHPÍøÒ³µÄ±àÂë
¡¡¡¡1.phpÎļþ±¾ÉíµÄ±àÂëÓëÍøÒ³µÄ±àÂëӦƥÅä
¡¡¡¡a.Èç¹ûÓûʹÓÃgb2312±àÂ룬ÄÇôphpÒªÊä³öÍ·£ºheader(“Content-Type: text/html; charset=gb2312")£¬¾²Ì¬Ò³ÃæÌí¼Ó£¬ËùÓÐÎļþµÄ±àÂë¸ñʽΪANSI£¬¿ÉÓüÇʱ¾´ò¿ª£¬Áí´æΪѡÔñ±àÂëΪANSI£¬¸²¸ÇÔ´Îļþ¡£
¡¡¡¡b.Èç¹ûÓûʹÓÃutf-8±àÂ룬ÄÇôphpÒªÊä³öÍ·£ºheader(“Content-Type: 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: Invalid argument in ...
¡¡¡¡Warning: move_uploaded_file()[function.move-uploaded-file]:Unable to move '' to '' in ...
¡¡¡¡Warning: filesize() [function.filesize]: stat failed for ... in ...
¡¡¡¡Warning: readfile() [function.readfile]: failed to open stream: Invalid argument in ..
¡¡¡¡ÔÚLinux»·¾³ÏÂÓÃgb2312±àÂëËäÈ»²»»á³öÏÖÕâЩ´íÎ󣬵«±£´æºóµÄÎļþÃû³öÏÖÂÒÂëµ¼ÖÂÎÞ·¨¶ÁÈ¡Îļþ£¬Õâʱ¿ÉÏȽ«²ÎÊýת»»³É²Ù×÷ϵͳʶ±ðµÄ±àÂ룬±àÂëת»»¿
Ïà¹ØÎĵµ£º
½ñÌ칤×÷ÖÐÓöµ½ÁËPOSTÊý¾ÝµÄÎÊÌ⣬ÐèÒªÏòÒ»¸öÌض¨µÄURL·¢ËÍPOSTÊý¾Ý¡£
ÏÖ½«PHP·¢ËÍPOSTÊý¾ÝµÄ·½Ê½×ܽáÏ£¬·½±ã×Ô¼ºÔ츣ºóÈË£º
·½·¨Ò»£ºHTTPº¯Êý·¢ËÍ·½Ê½
˵Ã÷£º$dataΪPOST·¢Ë͵ÄÊý¾Ý£º$keyΪ²ÎÊýÃû£¬$valΪ²ÎÊýÖµ
$URL = "http://pre.payment.sdoa.sdo.com/";
$data = $key1."=".val1."&".$key2."=".val2;
$Post ......
¶ÔÓÚÔËÐÐÔÚapacheÀïµÄphpÓ¦ÓÃÀ´Ëµ£¬static±äÁ¿µÄ×÷ÓÃÓòÊÇÒ»´ÎhttpÇëÇó¡£
¿ÉÒÔͨ¹ýÒÔÏ´úÂë½øÐÐÑéÖ¤£º
<?php
# test.php
function test(){
static $sss = 0;
++$sss;
echo $sss;
}
test();
?>
·ÃÎÊ/test.php £¬¿ÉÒÔ¿´µ½£¬×ÜÊÇ ......
ͼ±í¿â
ÏÂÃæµÄÀà¿â¿ÉÒÔÈÃÄãºÜ¼òµÄ´´½¨¸´ÔÓµÄͼ±íºÍͼƬ¡£µ±È»£¬ËüÃÇÐèÒªGD¿âµÄÖ§³Ö¡£
pChart - Ò»¸ö¿ÉÒÔ´´½¨Í³¼ÆͼµÄ¿â¡£
Libchart - ÕâÒ²ÊÇÒ»¸ö¼òµ¥µÄͳ¼Æͼ¿â¡£
JpGraph - Ò»¸öÃæÏò¶ÔÏóµÄͼƬ´´½¨Àà¡£
Open Flash Chart - ÕâÊÇÒ»¸ö»ùÓÚFlashµÄͳ¼Æͼ¡£
RSS ½âÎö
½âÊÍRSS²¢ÊÇÒ»¼þºÜµ¥µ÷µÄÊÂÇé£ ......
±¾À´²»Ïë̸Õâ¸ö³ÁÖصĻ°Ì⣬Æäʵ˵°×ÁË£¬Èç¹ûÄãÒ»¸öPHPµÄ³ÌÐòÔ±Á¬ÔõôÅäÖû·¾³¶¼¸ã²»¶¨Ä㻹¸ã¸öP¿ª·¢Ñ½¡£µÃ£¬ÔÛ²»ËµÄãÔÚlinuxÏÂÃæ¸ã¶¨ÕâЩ£¬ÄѵÀÄãÔÚwindowsÏÂÃæÄãÒ²¸ã²»¶¨£¿
ÏÖÔÚµÄPHP¶þ½øÖÆ°²×°°æ±¾ÒѾ¿ÉÒÔÖ§³Öapache,iis5,iis6µÈһЩWEB·þÎñÆ÷ÁË£¬ÎªÊ²Ã´»¹ÊÇÓÐһЩÈ˲»»áÅäÖÃÄØ£¿ÕæÏ벻ͨѽ¡£¡£¡£¡£¡£¡£
ÓÚÊÇÔÚÕâÖÖ´ó ......
1. Èç¹ûÒ»¸ö·½·¨Äܱ»¾²Ì¬£¬ÄǾÍÉùÃ÷ËûΪ¾²Ì¬µÄ£¬ËٶȿÉÌá¸ß1/4;
2. echoµÄЧÂʸßÓÚprint,ÒòΪechoûÓзµ»ØÖµ£¬print·µ»ØÒ»¸öÕûÐÍ;
3. ÔÚÑ»·Ö®Ç°ÉèÖÃÑ»·µÄ×î´ó´ÎÊý£¬¶ø·ÇÔÚÔÚÑ»·ÖÐ;
4. Ïú»Ù±äÁ¿È¥ÊÍ·ÅÄڴ棬ÌرðÊÇ´óµÄÊý×é;
5. ±ÜÃâʹÓÃÏñ__get, __set, __autoloadµÈħÊõ·½·¨;
6. requiere_once()±È½ÏºÄ×ÊÔ´;
7. ÔÚ ......