php5.4后htmlspecialchars输出为空的问题

´Ó¾É°æÉý¼¶µ½php5.4£¬¿ÖÅÂ×îÂé·³µÄ¾ÍÊÇhtmlspecialcharsÕâ¸öÎÊÌâÁË£¡µ±È»£¬htmlentitiesÒ²»áÊÜÓ°Ï죬²»¹ý£¬¶ÔÓÚÖÐÎÄÕ¾À´ËµÒ»°ãÓÃhtmlspecialchars±È½Ï³£¼û£¬htmlentities·Ç³£ÉÙÓõ½¡£

¿ÉÄÜÀÏÍâÈÏΪÍøÒ³ÆÕ±éÓ¦¸ÃÊÇutf-8±àÂëµÄ£¬ÓÚÊÇ¿àÁËÄÇЩÓÃGB2312£¬GBK±àÂëµÄÖÐÎÄÕ¾......£¡

¾ßÌå±íÏÖ£º

$str = "9enjoy.comµÄphp°æ±¾ÊÇ5.2.10";
echo htmlspecialchars($str);

gbk×Ö·û¼¯ÏÂÊä³öΪ¿Õ...utf-8Ï£¬Êä³öÕý³£¡£

ΪʲôÄØ£¬Ô­ÒòÔÚÓÚ5.4.0¶ÔÕâ¸öº¯ÊýµÄ±ä»¯£º

5.4.0   The default value for the encoding parameter was changed to UTF-8.

Ô­À´ÊÇʲôÄØ£¿

string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' [, bool $double_encode = true ]]] )

Defines encoding used in conversion. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.

Ô­À´ÊÇISO-8859-1£¬5.4ºóĬÈϱä³Éutf-8£¡È»ºóÖÐÎÄʹÓÃÕâ¸öº¯Êý¾ÍÊä³öΪ¿Õ°×ÁË¡£

¹úÄÚÒ»¶Ñ¿ªÔ´³ÌÐòÔÚ5.4϶¼»áÓÐÕâÑùµÄÎÊÌ⣬DISCUZ¹Ù·½Ò²½¨ÒéÓû§²»ÒªÉý¼¶µ½5.4¡£

½â¾ö·½°¸£º
1.¿à±ÆµÄÐÞ¸ÄËùÓÐÓõ½htmlspecialcharsµØ·½µÄ³ÌÐò

1.1 ÆäµÚ¶þ¸ö$flags²ÎÊý£¬Ä¬ÈÏÊÇENT_COMPAT£¬Òò´Ë¸Ä³É
htmlspecialchars($str,ENT_COMPAT,'GB2312');
Ϊʲô²»ÊÇGBK£¿ÒòΪûÓÐGBKÕâ¸ö²ÎÊý£¬Èç¹ûÇ¿ÐÐʹÓÃGBK£¬Ôò±¨´í¸øÄã¿´£º
Warning: htmlspecialchars(): charset `gbk' not supported, assuming utf-8
ΪÁËÄÜʹÓÃGBK£¬Ôò¸Ä³É£º
htmlspecialchars($str,ENT_COMPAT,'ISO-8859-1');

1.2.Ò»ÑùÊǸijÌÐò£¬µ«¿ÉÒÔÊ¡ÂÔÒ»¸ö²ÎÊý¡£
¿ÉÒÔÔÚÍøҳͷ²¿¼Ó
ini_set('default_charset','gbk');
È»ºó¸Ä³É
htmlspecialchars($str,ENT_COMPAT,'');
ÎĵµÖÐÓÐд£ºAn empty string activates detection from script encoding (Zend multibyte), default_charset and current locale (see nl_langinfo() and setlocale()), in this order. Not recommended.
´ó¸ÅÒâ˼¾ÍÊÇ£º´«Èë¿Õ×Ö·û´®ÔòʹÓÃdefault_charsetµÄ±àÂë

1.3.·â×°Ò»¸öº¯Êý°É...±¾À´htmlspecialcharsÕâ¸öµ¥´ÊÒ»Ö±²»ºÃ¼Ç¡£
function htmlout($str) {
return htmlspecialchars($str,ENT_COMPAT,'ISO-8859-1');
}
È»ºóÈ¥ÅúÁ¿Ìæ»»¡£

2.Ö±½ÓÐÞ¸ÄÔ´Â룬ÖرàÒ룡ÕâÒ²ÊÇÄ¿Ç°ÎÒÔÚÏßÉÏ×öµÄ·½°¸¡£
ÐÞ¸Äext/standard/html.c
´ó¸ÅÔÚ372ÐÐ
/* Default is now UTF-8 /
if (charset_hint == NULL)
return cs_utf_8;
°Ñcs_utf_8¸Ä³É cs_8859_1
/
Default is now UTF-8 */
if (charset_hint == NULL)
return cs_8859_1;
±àÒëºó£¬Ô­³ÌÐò¾Í²»ÓÃ×öÈκε÷ÕûÁË¡£
°²×°·½·¨¿É²Î¿¼£ºhttp://www.9enjoy.com/linux-upgrade-php54/

windowsÏÂÔõô°ì£¿Õâ¸ö£¬×Ô¼ºÏë°ì·¨±àÒë°É£¬ÄѶȱȽϴó...
Ìṩһ¸öÍøÖ·¹©²Î¿¼£ºhttp://www.phpvim.net/web/php/build-php5-4-and-xdebug-on-win32.html
ÒýÓÃÆäÒ»¾ä»°£º×¼±¸ºÃ¿§·È¡¢¿ÉÀÖ£¬×öºÃ×¼±¸£¬¿ÉÄÜÒªÕÛÌÚÊýСʱ¡­