What should I do if the Chinese input content obtained by php is not displayed?

藏色散人
Release: 2023-03-17 14:06:01
Original
1360 people have browsed it

The solution to the problem that php cannot display the input content in Chinese: 1. Open the corresponding php file; 2. Set the region information to the system default by adding the "setlocale(LC_ALL,NULL);" statement .

What should I do if the Chinese input content obtained by php is not displayed?

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if the Chinese input content obtained by php is not displayed?

php fgetcsv reads the file content, but the Chinese part always cannot be displayed. Solution

When using fgetcsv to read the file content, but the Chinese part always fails. Unable to display. If a piece of text contains letters and Chinese characters, the Chinese characters before the letters cannot be read, but the Chinese characters after the letters can be retained.

The first solution:

I checked the official PHP website and found that adding setlocale can solve the problem.

Originally, this problem did not occur when using PHP4. It may only happen with PHP5...

Note: The setlocale() function only changes the region information for the current script.

Tips: You can set the region information to the system default through setlocale(LC_ALL,NULL).

// utf-8
setlocale(LC_ALL, 'en_US.UTF-8');
// 简体
setlocale(LC_ALL, 'zh_CN');

//设置回系统默认
setlocale(LC_ALL,NULL);
Copy after login

The following are commonly used regional identifiers

zh_CN GB2312
en_US.UTF-8 UTF-8
zh_TW BIG5
zh_HK BIG5-HKSCS
zh_TW.EUC-TW EUC-TW
zh_TW.UTF-8 UTF-8
zh_HK.UTF-8 UTF-8
zh_CN.GBK GBK
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What should I do if the Chinese input content obtained by php is not displayed?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template