如何让服务器完全支持 UTF-8 编码?
想让服务器支持完整 UTF-8 编码的 Web 应用,但总是退回到 ISO-8859-1。
配置是 MySQL 5.6、PHP 5.5 和 Apache 2.2。
想知道具体地该在哪里设置编码?有没有必须要做的配置清单什么的,还麻烦指导一下。
回复内容:
想让服务器支持完整 UTF-8 编码的 Web 应用,但总是退回到 ISO-8859-1。
配置是 MySQL 5.6、PHP 5.5 和 Apache 2.2。
想知道具体地该在哪里设置编码?有没有必须要做的配置清单什么的,还麻烦指导一下。
mysql:
默认配置可以不用动,默认的lantin1编码支持utf-8的存储于读取。mysqldump备份的时候注意一下skip-charset即可。
php&apache:
在脚本的开头设置一下header("Content-Type:text/html;charset=UTF-8")
或者修改apache的配置(http.conf) AddDefaultCharset utf-8
html:
在生成的html页面中,添加
告知浏览器页面使用的编码,这样浏览器post提交上来的文本才会是utf-8的。
最后也是最重要的,你得保证你的页面文本本身是utf-8的,否则编码是gbk的,强制声明成utf-8的,浏览器显示出来也是乱码。
希望能帮到你 :)
mysql : set names utf8
php:
header Content-Type:text/html;charset=UTF-8
开发编码用UTF8
apache 不需要配置

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

Detailed explanation of the problem of deducting balances in combination with PHP optimistic locks and transactions in this article will analyze in detail a balance deduction using PHP, optimistic locks and database transactions, only...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Configure the apscheduler timing task as a service on macOS platform, if you want to configure the apscheduler timing task as a service, similar to ngin...
