Home Database Mysql Tutorial PHP乱码来源分析

PHP乱码来源分析

Jun 01, 2016 pm 01:15 PM
New software project

PHP项目出现乱码,原因就是软件之间,模板之间的编码有差异,不相同:

  1. 新建".html", ".php" , ".tpl" , ."js" , ".css"等文件使用utf8统一的编码格式;
  2. 开发工具中设置默认新建文件时的编码格式;
  3. mysql_query("set character set 'utf8'");          //读库

  4. mysql_query("set names 'utf8'");                  //写库

  5. default-character-set=utf8                         //MySQL配置文件"my.ini"编码设置
  6. init-connect=/'SET NAMES utf8/'                 //MySQL配置文件"my.ini"编码设置
  7. collation_server=utf8_unicode_ci               //MySQL配置文件"my.ini"编码设置
  8. character_set_server=utf8                       //MySQL配置文件"my.ini"编码设置
  9. default_charset = "UTF-8"                       //php配置文件"php.ini"编码设置
  10. header(“Content-Type: text/html; charset=utf-8″);    //php 文件输出头
  11. header("Cache-Control:no-cache");                          //php文件输出头
  12.       //html页面中使用的编码

  13. 在phpMyAdmin中修改mysql中数据库,数据表及数据字段的字符编码格式;                //编码设为:utf8_general_ci
  14. 数据库执行语句 :CREATEDATABASE`dbname`DEFAULTCHARACTERSETutf8 COLLATE utf8_general_ci;
  15. 待续...

补充: 
# Lang-abbvCharset     Language
#---------------------------------
en         ISO-8859-1  English
UTF-8      utf8        UTF-8
Unicode     ucs         Unicode
th          Cp874       Thai
ja          SJIS        Japanese
ko          Cp949       Korean
zh          Cp950       Chinese-Traditional
zh-cn      GB2312      Chinese-Simplified
zh-tw       Cp950       Chinese
cs          ISO-8859-2  Czech
hu          ISO-8859-2  Hungarian
hr          ISO-8859-2  Croation
pl          ISO-8859-2  Polish
ro          ISO-8859-2  Romanian
sr          ISO-8859-2  Serbian
sk          ISO-8859-2  Slovak
sl          ISO-8859-2  Slovenian
sq          ISO-8859-2  Albanian
bg          ISO-8859-5  Bulgarian
be          ISO-8859-5  Byelorussian
mk          ISO-8859-5  Macedonian
ru          ISO-8859-5  Russian
uk          ISO-8859-5  Ukrainian
ca          ISO-8859-1  Catalan
de          ISO-8859-1  German
da          ISO-8859-1  Danish
fi          ISO-8859-1  Finnish
fr          ISO-8859-1  French
es          ISO-8859-1  Spanish
is          ISO-8859-1  Icelandic
it          ISO-8859-1  Italian
nl          ISO-8859-1  Dutch
no          ISO-8859-1  Norwegian
pt          ISO-8859-1  Portuguese
sv          ISO-8859-1  Swedish
af          ISO-8859-1  Afrikaans
eu          ISO-8859-1  Basque
fo          ISO-8859-1  Faroese
gl          ISO-8859-1  Galician
ga          ISO-8859-1  Irish
gd          ISO-8859-1  Scottish
mt          ISO-8859-3  Maltese
eo          ISO-8859-3  Esperanto
el          ISO-8859-7  Greek
tr          ISO-8859-9  Turkish
he          ISO-8859-8  Hebrew
iw          ISO-8859-8  Hebrew
ar          ISO-8859-6  Arabic
et          ISO-8859-1  Estonian
lv          ISO-8859-2  Latvian
lt          ISO-8859-2  Lithuanian
                       

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 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months 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)

What to do if WPS Office cannot open the PPT file - What to do if WPS Office cannot open the PPT file What to do if WPS Office cannot open the PPT file - What to do if WPS Office cannot open the PPT file Mar 04, 2024 am 11:40 AM

Recently, many friends have asked me what to do if WPSOffice cannot open PPT files. Next, let us learn how to solve the problem of WPSOffice not being able to open PPT files. I hope it can help everyone. 1. First open WPSOffice and enter the homepage, as shown in the figure below. 2. Then enter the keyword "document repair" in the search bar above, and then click to open the document repair tool, as shown in the figure below. 3. Then import the PPT file for repair, as shown in the figure below.

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

CrystalDiskinfo usage tutorial-What software is CrystalDiskinfo? CrystalDiskinfo usage tutorial-What software is CrystalDiskinfo? Mar 18, 2024 pm 04:50 PM

CrystalDiskInfo is a software used to check computer hardware devices. In this software, we can check our own computer hardware, such as reading speed, transmission mode, interface, etc.! So in addition to these functions, how to use CrystalDiskInfo and what exactly is CrystalDiskInfo? Let me sort it out for you! 1. The Origin of CrystalDiskInfo As one of the three major components of a computer host, a solid-state drive is the storage medium of a computer and is responsible for computer data storage. A good solid-state drive can speed up file reading and affect consumer experience. When consumers receive new devices, they can use third-party software or other SSDs to

Can AI conquer Fermat's last theorem? Mathematician gave up 5 years of his career to turn 100 pages of proof into code Can AI conquer Fermat's last theorem? Mathematician gave up 5 years of his career to turn 100 pages of proof into code Apr 09, 2024 pm 03:20 PM

Fermat's last theorem, about to be conquered by AI? And the most meaningful part of the whole thing is that Fermat’s Last Theorem, which AI is about to solve, is precisely to prove that AI is useless. Once upon a time, mathematics belonged to the realm of pure human intelligence; now, this territory is being deciphered and trampled by advanced algorithms. Image Fermat's Last Theorem is a "notorious" puzzle that has puzzled mathematicians for centuries. It was proven in 1993, and now mathematicians have a big plan: to recreate the proof using computers. They hope that any logical errors in this version of the proof can be checked by a computer. Project address: https://github.com/riccardobrasca/flt

How to set the keyboard increment in Adobe Illustrator CS6 - How to set the keyboard increment in Adobe Illustrator CS6 How to set the keyboard increment in Adobe Illustrator CS6 - How to set the keyboard increment in Adobe Illustrator CS6 Mar 04, 2024 pm 06:04 PM

Many users are using the Adobe Illustrator CS6 software in their offices, so do you know how to set the keyboard increment in Adobe Illustrator CS6? Then, the editor will bring you the method of setting the keyboard increment in Adobe Illustrator CS6. Interested users can take a look below. Step 1: Start Adobe Illustrator CS6 software, as shown in the figure below. Step 2: In the menu bar, click the [Edit] → [Preferences] → [General] command in sequence. Step 3: The [Keyboard Increment] dialog box pops up, enter the required number in the [Keyboard Increment] text box, and finally click the [OK] button. Step 4: Use the shortcut key [Ctrl]

How to resolve an incompatible software attempt to load with Edge? How to resolve an incompatible software attempt to load with Edge? Mar 15, 2024 pm 01:34 PM

When we use the Edge browser, sometimes incompatible software attempts to be loaded together, so what is going on? Let this site carefully introduce to users how to solve the problem of trying to load incompatible software with Edge. How to solve an incompatible software trying to load with Edge Solution 1: Search IE in the start menu and access it directly with IE. Solution 2: Note: Modifying the registry may cause system failure, so operate with caution. Modify registry parameters. 1. Enter regedit during operation. 2. Find the path\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Micros

What software is photoshopcs5? -photoshopcs5 usage tutorial What software is photoshopcs5? -photoshopcs5 usage tutorial Mar 19, 2024 am 09:04 AM

PhotoshopCS is the abbreviation of Photoshop Creative Suite. It is a software produced by Adobe and is widely used in graphic design and image processing. As a novice learning PS, let me explain to you today what software photoshopcs5 is and how to use photoshopcs5. 1. What software is photoshop cs5? Adobe Photoshop CS5 Extended is ideal for professionals in film, video and multimedia fields, graphic and web designers who use 3D and animation, and professionals in engineering and scientific fields. Render a 3D image and merge it into a 2D composite image. Edit videos easily

How to delete recently opened files in Adobe Reader XI - How to delete recently opened files in Adobe Reader XI How to delete recently opened files in Adobe Reader XI - How to delete recently opened files in Adobe Reader XI Mar 04, 2024 am 11:13 AM

Recently, many friends have asked me how to delete recently opened files in Adobe Reader XI. Next, let us learn how to delete recently opened files in Adobe Reader XI. I hope it can help everyone. Step 1: First, use the "win+R" shortcut key to open the run, enter "regedit", and press Enter to open it, as shown in the picture. Step 2: After entering the new interface, click "HKEY_CURRENT_USERSoftwareAdobeAcrobatReader11.0AVGeneralcRecentFiles" on the left, select "c1", right-click and select the "Delete" option, as shown in the figure. Step 3: Then pop up

See all articles