xml½âÎö問題 - PHP / »ù´¡±à³Ì
為ʲ麼ÎÒÉú³ÉµÄ時ºòÊÇbig5編碼µÄxml£¬µ«ÎÒ½âÎöÖ®áá卻發現xml內ÈݵÄ編碼蠻³ÉÁËutf-8µÄ£¬這ÊÇ為ʲ麼
<?xml version='1.0' encoding='big5' ?>
<editorial>
<header>
</header>
<body>
<title_1>Greenhouse</title_1>
<subheading_1>A New Experience</subheading_1>
<paragraph_1><p>»¢Ø¾ÄÀ¡¡Ð¡Æð碼Æó載ÄÀ¡¡Ôеشó</p></paragraph_1>
</body>
</editorial>
這ÊÇÎÒÉú³ÉµÄxmlÎļþ
function hookHome($params)
{
if (file_exists('modules/editorial/editorial.xml'))
{
if ($xml = simplexml_load_file('modules/editorial/editorial.xml'))
{
global $cookie, $smarty;
$smarty->assign(array(
'xml' => $xml,
'homepage_logo' => file_exists('modules/editorial/homepage_logo.jpg'),
'logo_subheading' => 'logo_subheading_'.$cookie->id_lang,
'title' => 'title_'.$cookie->id_lang,
'subheading' => 'subheading_'.$cookie->id_lang,
'paragraph' => 'paragraph_'.$cookie->id_lang,
'this_path' => $this->_path
));
return $this->display(__FILE__, 'editorial.tpl');
}
}
return false;
}
這ÊǽâÎöxmlÎļþ display·½·¨無關
Ïà¹ØÎÊ´ð£º
Ôڲɼ¯Ò»¸öÒ³ÃæµÄʱºòͨ³£¶¼ÊÇʹÓÃfile_get_contents($url)
²»¹ý·µ»ØµÄ½á¹ûÓÐʱºò»á²»È«
Èç¹ûÔÚhtmlÖÐʹÓà document.ready,ÔÚÒ³Ãæ×¼±¸ºÃºó£¬Ê¹ÓÃajax¶ÁÈ¡±ðÒ»²¿·ÖµÄÊý¾Ý
ÔÙͨ¹ýÐÞ¸Ähtml±êÇ©µÄÄÚÈÝ£¬¾Í²¿·ÖµÄÊý¾Ý¾ ......
ΪʲôÎҵijÌÐòµ÷ÓÃXMLÅäÖÃÎļþÖеİ¢À²®ÎÄÏÔʾ²»³öÀ´£¿ÆäËûµÄÓïÖÖ¶¼¿ÉÒÔ£¬ÈçÖÐÎÄ£¬Ó¢ÎÄ£¬µÂÎͼ¿É¡£
ÎÒ½«XMLµÄ±àÂë¸ÄΪutf-8ºÍunicodeµÄµ½µÃ½á¹û¶¼Ò»Ñù.
°¢À²®ÎĵÄ×Ö¿âÄãÓÐô£¿
ÓÐ,ÎÒµÄEXEÊÇ·ÅÔÚpc»úÉÏÖ´Ðе ......
Çë½Ì¸ßÊÖ°ïæ£¬session_start£¨£©·ÅÔÚÍⲿµÄÎļþÓà require »ò include °üº¬½øÀ´£¬ÇëÎÊÕâÑù×öºÏÀíÂ𣿣¿´úÂëÔËÐÐÊÇÕý³£µÄ£¬ÕâÑù×öºÏÀíÂ𣿣¿Çë¸ßÊÖÖ¸µã¡£¡£¡£¡£ лл····
require »ò include ......
¼±Çó£ºÔÚphp½Å±¾ÀïÔõôµ÷ÓÃjsÎļþÀï·½·¨£¿
»òÕßÔÚjsÎļþÀïµ÷ÓÃphpÎļþдµÄseesion£¿
PHP¸ÕÈëÃÅѧϰ,ÓÑÇé¶¥Ò»¸ö
¼±Çó£ºÔÚphp½Å±¾ÀïÔõôµ÷ÓÃjsÎļþÀï·½·¨£¿
//echo '<script>alert("ok");< ......