Home  >  Article  >  Backend Development  >  smarty模板输出字符乱码解决方法

smarty模板输出字符乱码解决方法

WBOY
WBOYOriginal
2016-06-13 11:59:031160browse

smarty模板输出字符乱码
我创建了config.conf作为配置文件,想运用smarty模板导入并在页面输出
PHP,html和config.conf为编码方式都为utf8,firefox浏览器unicode
页面却出乱码

我将config.conf改成ANSI编码方式

我推断可能与smarty本身的编码方式有关
我从其他人那里拷贝了一个smarty包(我自己的是从官网上下载最新版本的),页面显示正常没有乱码。

config.conf输入信息如下

<br />webTitle=当当网,全球最大的中文网上书店<br />copyRight=当当网<br />icpNum = 123456<br />


html代码
<br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html xmlns="http://www.w3.org/1999/xhtml"><br /><head><br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br /><{config_load file="config.conf"}><br /><title><{#webTitle#}></title><br /></head><br /><br /><body><br /><br />---------配置文件demo----------<br /><br /><table align="center" width="400" cellpadding="0" cellspacing="0" border="1"><br />	<tr><br />		<td>copyright</td><br />		<td><{#copyRight#}></td><br />		<td><{#icpNum#}></td><br />	</tr><br /></table><br /></body><br /></html><br />


PHP代码
<br /><?php <br />require_once("smarty/Smarty.class.php");<br />$smarty=new Smarty();<br />$smarty->left_delimiter="<{";<br />$smarty->right_delimiter="}>";<br />$smarty->display("index.html");<br /><br />?><br />


我想问如果还是用原来的smarty包,如何解决以上问题,谢谢各位
------解决方案--------------------
把 config.conf 改成无bom的utf-8编码试试。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn