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');
}
}這是解析xml並放到smarty中<!-- Module Editorial -->
<div id="editorial_block_center" class="editorial_block">
{if $xml->body->home_logo_link}<a href="{$xml->body->home_logo_link|escape:'htmlall':'big5'}" title="{$xml->body->$title|escape:'htmlall':'big5'|stripslashes}">{/if}
{if $homepage_logo}<img src="{$this_path}homepage_logo.jpg" alt="{$xml->body->$title|escape:'htmlall':'big5'|stripslashes}" />{/if}
{if $xml->body->home_logo_link}</a>{/if}
{if $xml->body->$logo_subheading}{$xml->body->$logo_subheading|stripslashes}{/if}
{if $xml->body->$title}<h2>{$xml->body->$title|stripslashes}</h2>{/if}
{if $xml->body->$subheading}<h3>{$xml->body->$subheading|stripslashes}</h3>{/if}
{if $xml->body->$paragraph}<div class="rte" ><?php var_dump(iconv('utf-8','big5',{$xml->body->$paragraph|stripslashes})); ?> </div>{/if}
</div>
這是一個.tpl文件,我需要正常顯示xml裡面的編碼為big5的中文文字,請哪個大牛幫幫忙!!!
這樣解析的xml文件編碼為utf-8,而.tpl文件是big5的,直接這樣顯示會有亂碼?要如何做才能顯示正常?
{
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');
}
}這是解析xml並放到smarty中<!-- Module Editorial -->
<div id="editorial_block_center" class="editorial_block">
{if $xml->body->home_logo_link}<a href="{$xml->body->home_logo_link|escape:'htmlall':'big5'}" title="{$xml->body->$title|escape:'htmlall':'big5'|stripslashes}">{/if}
{if $homepage_logo}<img src="{$this_path}homepage_logo.jpg" alt="{$xml->body->$title|escape:'htmlall':'big5'|stripslashes}" />{/if}
{if $xml->body->home_logo_link}</a>{/if}
{if $xml->body->$logo_subheading}{$xml->body->$logo_subheading|stripslashes}{/if}
{if $xml->body->$title}<h2>{$xml->body->$title|stripslashes}</h2>{/if}
{if $xml->body->$subheading}<h3>{$xml->body->$subheading|stripslashes}</h3>{/if}
{if $xml->body->$paragraph}<div class="rte" ><?php var_dump(iconv('utf-8','big5',{$xml->body->$paragraph|stripslashes})); ?> </div>{/if}
</div>
這是一個.tpl文件,我需要正常顯示xml裡面的編碼為big5的中文文字,請哪個大牛幫幫忙!!!
這樣解析的xml文件編碼為utf-8,而.tpl文件是big5的,直接這樣顯示會有亂碼?要如何做才能顯示正常?
解决方案 »
- 请问CENTOS如何连接SQL SERVER呢?
- var_dump(in_array('兽兽', range(0, 9)));
- 招聘【兼职】PHP/python工程师(急)
- php人员
- iconv("UTF-8","GBK",$_POST["Notes"])不能正常显示数据
- PHP 把几张图片合成到为一张固定大小的图片
- 留言版中插入图片链接
- 在form表单中有这种PHP的用法吗?<input type="text" onKeyPress="<?php a(); ?>" name="show">,详情请进。
- 所文本操作,急急急急急急急急急急急急急急急急急急
- 新闻系统
- 哪位老大看看有什么错误,总是出错。
- 诡异。update执行不了
需要mbstring这个,一般搞php应该知道~
实在需要的话。那就只有自定义smarty的组合修改器了
eg:
{$xml->body->$title|修改器名称:'utf-8':'big5'}
自定义要在:
smarty\plugins
目录下新建:
modifier.修改器名称.php文件:
内容如下:
function smarty_modifier_修改器名称($string, $scharset, $tcharset)
{
return iconv($scharset,$tcharset,$string);
}