Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial smarty模板输出字符乱码

smarty模板输出字符乱码

Jun 23, 2016 pm 01:56 PM
smarty Garbled characters character template output

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

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

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

config.conf输入信息如下

1

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

Copy after login


html代码

1

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

Copy after login


PHP代码

1

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

Copy after login


我想问如果还是用原来的smarty包,如何解决以上问题,谢谢各位


回复讨论(解决方案)

把 config.conf 改成无bom的utf-8编码试试。

把 config.conf 改成无bom的utf-8编码试试。



多谢楼上!我看了一些帖子,用记事本保存的是有BOM的,而PHP是不支持BOM的,会导致出错。
最后我通过用PHP保存成PHP文件,修改后缀,错误修正。
Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve Chinese garbled characters in Linux How to solve Chinese garbled characters in Linux Feb 21, 2024 am 10:48 AM

The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

Methods and detailed analysis to solve the problem of garbled characters in some win11 software Methods and detailed analysis to solve the problem of garbled characters in some win11 software Jan 30, 2024 pm 03:54 PM

Many users found that their personal software was garbled after upgrading the win11 system. So how to solve this problem? Now let the editor carefully introduce to users the analysis of garbled code problems in some software in win11. Analysis of garbled characters in some software in win11 1. Click the search box in the taskbar in the lower left corner and enter control panel to open it. 3. Click on the area. 5. Then uncheck the small box for beta version in the window, and finally restart the computer to solve the problem.

How to solve the problem of garbled characters when importing Chinese data into Oracle? How to solve the problem of garbled characters when importing Chinese data into Oracle? Mar 10, 2024 am 09:54 AM

Title: Methods and code examples to solve the problem of garbled characters when importing Chinese data into Oracle. When importing Chinese data into Oracle database, garbled characters often appear. This may be due to incorrect database character set settings or encoding conversion problems during the import process. . In order to solve this problem, we can take some methods to ensure that the imported Chinese data can be displayed correctly. The following are some solutions and specific code examples: 1. Check the database character set settings In the Oracle database, the character set settings are

Tips for dealing with garbled Chinese file names in PHP Tips for dealing with garbled Chinese file names in PHP Feb 27, 2024 pm 02:18 PM

Tips for dealing with garbled Chinese file names in PHP During the development process, we often encounter the problem of garbled Chinese file names, especially when processing files uploaded by users. In PHP, how to correctly handle garbled file names is a common and important problem. This article will introduce some techniques for dealing with garbled Chinese file names and provide specific code examples to help readers better deal with this challenge. Problem description: When users upload files, the Chinese file names sometimes appear to be garbled. This is because different operating systems and browsers

How to solve the problem of garbled characters displayed on Win11 when booting? Two solutions to the garbled characters displayed on Win11 boot How to solve the problem of garbled characters displayed on Win11 when booting? Two solutions to the garbled characters displayed on Win11 boot Feb 29, 2024 pm 12:16 PM

Win11 is Microsoft's latest operating system, but some users may encounter the problem of displaying garbled characters when booting, which will affect the normal use of the system. This article will introduce some methods to solve this problem. Method 1: 1. Press the [Win+S] key combination, or click the [Search icon] next to the start icon on the taskbar. In the opened Windows search, enter [Control Panel] in the search box, and then click [Open]. The best matching control panel application out of the control panel window; 2. In the control panel window, switch to the [Category] view mode, and then click [Clock and Zone-Region]; 3. In the zone window, switch to the [Management] tab, and then click [Change] System Regional Settings]; 4. [Uncheck] Beta version: Use Unicode

How to deal with garbled characters in Linux terminal How to deal with garbled characters in Linux terminal Mar 20, 2024 pm 03:12 PM

How to deal with the problem of garbled characters in the Linux terminal. When using the Linux system, sometimes the text displayed in the terminal will be garbled. This brings inconvenience to us when using the terminal and needs to be dealt with in time. This article will introduce how to deal with some common Linux terminal garbled problems, and provide specific code examples. Problem 1: Garbled Chinese characters on the terminal. Garbled Chinese characters on the terminal are usually caused by incorrect character encoding settings on the terminal. We can solve this problem by modifying the terminal's character encoding settings. #View the current terminal

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

Regarding PPT masking, many people must be unfamiliar with it. Most people do not understand it thoroughly when making PPT, but just make it up to make what they like. Therefore, many people do not know what PPT masking means, nor do they understand it. I know what this mask does, and I don’t even know that it can make the picture less monotonous. Friends who want to learn, come and learn, and add some PPT masks to your PPT pictures. Make it less monotonous. So, how to add a PPT mask? Please read below. 1. First we open PPT, select a blank picture, then right-click [Set Background Format] and select a solid color. 2. Click [Insert], word art, enter the word 3. Click [Insert], click [Shape]

Strategies and techniques for solving Chinese garbled characters in Oracle database Strategies and techniques for solving Chinese garbled characters in Oracle database Mar 08, 2024 am 09:48 AM

Strategies and techniques for solving Chinese garbled characters in Oracle database. In actual database applications, many developers or administrators may encounter the problem of Chinese garbled characters in Oracle database. When the data in the database is garbled, it not only affects the correctness and readability of the data, but also brings many problems to the system. This article will combine specific code examples to introduce the strategies and techniques for solving Chinese garbled characters in Oracle database to help readers better understand and solve this problem. 1. The reason for garbled characters is inconsistent character sets: database connection and application

See all articles