ÍêÃÀ½â¾ö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±àÂëËäÈ»²»»á³öÏÖÕâЩ´íÎ󣬵«±£´æºóµÄÎļþÃû³öÏÖÂÒÂëµ¼ÖÂÎÞ·¨¶ÁÈ¡Îļþ£¬Õâʱ¿ÉÏȽ«²ÎÊýת»»³É²Ù×÷ϵͳʶ±ðµÄ±àÂ룬±àÂëת»»¿
Ïà¹ØÎĵµ£º
PHP ÏòËüÔËÐеÄÈκνű¾ÌṩÁË´óÁ¿µÄÔ¤¶¨Òå³£Á¿
¡£²»¹ýºÜ¶à³£Á¿¶¼ÊÇÓɲ»Í¬µÄÀ©Õ¹¿â¶¨ÒåµÄ£¬Ö»ÓÐÔÚ¼ÓÔØÁËÕâЩÀ©Õ¹¿âʱ²Å»á³öÏÖ£¬»òÕ߶¯Ì¬¼ÓÔغ󣬻òÕßÔÚ±àÒëʱÒѾ°üÀ¨½øÈ¥ÁË¡£
ÓÐÎå¸öħÊõ³£Á¿¸ù¾ÝËüÃÇʹÓõÄλÖöø¸Ä±ä¡£ÀýÈç __LINE__
µÄÖµ¾ÍÒÀÀµÓÚËüÔڽű¾ÖÐËù´¦µÄÐÐÀ´¾ö¶¨¡£ÕâЩÌØÊâµÄ³£Á¿²»Çø·Ö´óСд£¬ÈçÏ£º
±í 13 ......
½ñÌ칤×÷ÖÐÓöµ½ÁËPOSTÊý¾ÝµÄÎÊÌ⣬ÐèÒªÏòÒ»¸öÌض¨µÄURL·¢ËÍPOSTÊý¾Ý¡£
ÏÖ½«PHP·¢ËÍPOSTÊý¾ÝµÄ·½Ê½×ܽáÏ£¬·½±ã×Ô¼ºÔ츣ºóÈË£º
·½·¨Ò»£ºHTTPº¯Êý·¢ËÍ·½Ê½
˵Ã÷£º$dataΪPOST·¢Ë͵ÄÊý¾Ý£º$keyΪ²ÎÊýÃû£¬$valΪ²ÎÊýÖµ
$URL = "http://pre.payment.sdoa.sdo.com/";
$data = $key1."=".val1."&".$key2."=".val2;
$Post ......
; ±¾ÎIJ¢·ÇÊǶÔÓ¢ÎÄ°æ php.ini µÄ¼òµ¥·Ò룬¶øÊDzο¼ÁËÖÚ¶à×ÊÁÏÒԺ󣬽áºÏ×Ô¼ºµÄÀí½â£¬Ôö¼ÓÁËÐí¶àÄÚÈÝ£¬
; °üÀ¨ÔÚÔÓÐ php.ini »ù´¡ÉÏÔö¼ÓÁËһЩʵÓÃÄ£¿éµÄÅäÖÃ˵Ã÷£¬Í¬Ê±¶ÔÎļþÄÚÈݵİ²ÅŽøÐÐÁ˵÷Õû¡£
; ÓÉÓÚ×÷Õß²»Ï²»¶ no-free µÄÍæÒâ¶ù£¬ËùÒÔɾ³ýÁ˳ý MySQL ºÍ PostgreSQL ÒÔÍâµÄÆäËûÊý¾Ý¿âÄ£¿éÅäÖÃÑ¡Ïî¡£
;;;;;;;;;; ......
Ê×ÏÈ´´½¨½«´«Êä¸øÓû§µÄÊý¾ÝÎļþ¡£Õâ¸öÎļþ¿ÉÒÔÓÐÈκÎÄÚÈÝ£¬²»Óõ£ÐÄ£¬ÒòΪÓû§ÓÀÔ¶¶¼¿´²»µ½Õâ¸öÎļþ¡£ÎÒÃÇ¿¼ÂÇÉú³É´óÁ¿Îı¾²¢Ð´Èëµ½ÎļþÀ´´´½¨´ËÎļþ¡£ÀýÈçϱߵĽű¾½«Éú³ÉÒ»¸ö´óÔ¼1500KBµÄÎı¾Îļþ¡££¨ÔÝÖ»ÌṩÕâ¸ö˼·£¬¾ßÌåÂÔ..£©
<?php
/*=====http://hi.csdn.net/yinyiniao=====*/
$fp=fopen("cs.txt","w");
......
<?php
//$str = "abcdef¡ôÖлªÈËÃñ¹²ºÍ¹ú";
//$str = "1234567890";
$str = "ÖлªÈËÃñ¹²ºÍ¹úabcÖлªÈËÃñ¹²ºÍ¹úÖлªÈËÃñ¹²ºÍ¹ú";
$str = cut_str($str, 18);
echo $str;
function cut_str($str, $len){
if(strlen($str) <= $len) return $str;
$n = 0;
$tempstr = '';
for($i = 0; ......