Linux php.ini Chinese garbled solution: first find and open the "php.ini" configuration file; then find the statement about character encoding settings; finally change "iso-8859-1" to "utf -8" is enough.
The operating environment of this article: windows7 system, php5 version, DELL G3 computer
Solution to Chinese garbled characters in Linux php Method
Today, when running the php program, garbled characters appeared where Chinese characters should appear. Later, when I searched for a solution, I found that it was a problem with character encoding settings. Here are several solutions.
Without involving database encoding: we can modify the statement about character encoding settings in "/etc/php5/apache2/php.ini".
sudo vi /etc/php5/apache2/php.ini
After opening the file, press "/default_charset" to search,
Press the Enter key to find the location of default_charset and modify it.
Remove the comments, that is, remove the ";" and change iso-8859-1 to utf-8.
## Then restart Apache,
Sudo /etc/init.d/apache2 restart
Then in Firefox, enter your webpage address That's it.
The following are other methods, but I have not tried them. After all, the problem is solved. Provided for your reference.
(1) Generally speaking, for encoding compatibility reasons, most pages define the page character set as utf-8
At this time, to display Chinese normally, you need to convert the encoding method, such as
echo iconf("GB2312","UTF-8 ",'Chinese');
will not be garbled.
(2) Add
header("Content-Type:text/html;charset=gb2312");
(3) in front of the echo in php Of course, Simplified Chinese pages can also simply use
Change UTF-8 in to gb2312.
## Recommended learning: "
"
The above is the detailed content of Solution to linux php.ini Chinese garbled characters. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

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

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),

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

Dreamweaver CS6
Visual web development tools