Home > Article > Backend Development > What should I do if the Chinese input content obtained by php is not displayed?
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 .
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);
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
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!