Garbled characters in php web pages are generally caused by the difference between the encoding used when creating the database and the encoding of the php web page.
If you do not specify the encoding for the database created with phpmyadmin, the default encoding is latin1_swedish_ci, which means Swedish is not size-sensitive. Write, and the web pages we make in China are either GBK or GB2312 encoded, so it would be strange if there are no garbled characters.
1. Specify the encoding when creating the database.
Here again Let me talk about the commonly used encodings to avoid confusion for novices:
If you are making a simplified Chinese web page, then you use GB2312 encoding, gb2312_chinese_ci when building the database.
If you are doing It is a traditional Chinese web page, so when you create the database, you must use gib5 encoding, big5_chinese_ci
If the web page you make has both simplified and traditional Chinese, it is recommended that you use GBK encoding, gbk_chinese_ci. GBK contains more character codes than GB2312 Many, of course Traditional Chinese is also included.
If you are making a multi-language web page, it is recommended that you use UTF-8 encoding. There are two utf8 encoding options in mysql: utf8_unicode_ci and utf8_general_ci. The author generally uses utf8_general_ci , Regarding the difference between these two encodings, please refer to another article on this site: The difference between the proofreading set utf8_unicode_ci and utf8_general_ci in Mysql
We use UTF-8 encoding as an example to create a database as shown in the figure:
Syntax: mysql_query("SET NAMES 'utf8'");
For example:
$conn=mysql_connect('127.0.0.1','root ','123456');
mysql_query("set names 'utf8'",$conn); //Solving garbled characters
mysql_select_db('test1',$conn);
Under normal circumstances, as long as you do these two steps, your program will not have garbled characters
Second general situation:
The second general situation generally does not occur much, and mostly occurs when doing There are many programming languages. For example, sometimes we make utf8, sometimes we make gb2312, and sometimes we make big5 web pages. The encoding of the .php file created with the IDE is different from the encoding to be displayed by the program.
For example, I Last time I made a gb2312 simplified Chinese web page, and now my boss has asked me to make a gbi5 web page, but my IDE uses the gb2312 encoding
Take my commonly used IDE Dreamweaver as an example
If you still can’t figure it out, add a line of http header information to the head of the web page
header("Content-Type: text/html; charset=utf-8" ; The garbled code may be caused by the situation.
http://www.bkjia.com/PHPjc/325214.html
www.bkjia.com

Golang(Go编程语言)是一种基于C语言的编程语言,被广泛用于Web开发、网络编程、操作系统等领域。然而,在编写Golang程序时经常会遇到一个常见的问题,就是“undeclaredname”(未声明名称)错误。下面将介绍如何解决这个问题。了解错误信息在编译和运行Golang程序时,如果遇到了未声明名称错误,会在控制台输出相应的错误信

Java中的ClassNotFoundException是一种常见的编译错误。当我们尝试使用Java虚拟机(JVM)加载某个类时,如果JVM找不到该类,就会抛出ClassNotFoundException。这个错误可能出现在程序运行时,也可能出现在编译时。在本文中,我们将讨论什么是ClassNotFoundException,它为什么会发生以及如何解决它。C

随着Java的广泛应用,Java程序在连接数据库时经常会出现JDBC错误。JDBC(JavaDatabaseConnectivity)是Java中用于连接数据库的编程接口,因此,JDBC错误是在Java程序与数据库交互时遇到的一种错误。下面将介绍一些最常见的JDBC错误及如何解决和避免它们。ClassNotFoundException这是最常见的JDBC

Go语言是一门越来越受欢迎的编程语言,它的简洁、高效、易于编写的特点已经被越来越多的开发者所认可。而在Go语言开发中,遇到编译错误是不可避免的。其中一个常见的错误就是“undefined:json.Marshal”。这个错误通常发生在你使用了Go标准库的“encoding/json”包时,编译器提示找不到“json.Marshal”的定义。这个问题的根本原

Go语言作为一门快速发展的编程语言,被广泛应用于各种项目和领域。然而,在使用golang编写程序时,你有可能会遇到一些报错,其中一个常见的报错是“undefinedvariableorfunction”。那么,这个错误是什么意思?它是如何产生的?又该如何解决呢?本文将会对这些问题进行探讨。首先,我们需要了解一些基本概念。在golang中,变量和函数是两

在Vue应用中遇到“SyntaxError:Unexpectedtoken”怎么解决?Vue是前端开发中广泛使用的一个JavaScript框架,它可以让我们更轻松地管理页面的状态、渲染和交互。但是在编写Vue应用时,有时会遇到“SyntaxError:Unexpectedtoken”报错,这个错误提示意味着代码中存在语法错误,JavaScript引擎

Java作为目前最受欢迎的编程语言之一,在开发过程中常常会遇到各种各样的错误,其中Gradle错误是比较常见的一种。本文将介绍如何解决和避免Gradle错误。一、Gradle错误的原因Gradle为构建工具,其主要作用是将代码、资源文件、第三方库等打包并生成可执行的应用程序。在实际开发中,如果不注意一些细节,很容易出现Gradle错误,主要原因通常有以下几种

近年来,Golang一直受到越来越多开发者的青睐。但是,即使是最有经验的开发人员也会遇到一些挫折,比如一些报错。其中,一种常见的报错是:“invaliduseof,operator”。在这篇文章中,我将为大家介绍这个报错的原因,以及解决方法。首先,我们需要了解什么是","操作符。在Golang中,","操作符通常被用来在数组、参数列表或结构体中分隔不


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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
