For help: nginx + php Chinese characters are always garbled and already tried:
1. Changing the Linux character set to zh_cn.utf-8
2. charset in nginx has been set to UTF-8
3. php files are stored in UTF-8 format.
4. added the php file header
However, Chinese characters cannot be displayed when a webpage is opened.
The PHP file is as follows:
@ Header ('content-type: text/html; charset = UTF-8 ');
Echo "my first PHP script! ";
?>
The webpage output is:
????? PHP ??!
Reply to discussion (solution)
Add:
If you open a UTF-8 text file on the server, Chinese characters are displayed normally.
Two fewer"
Two fewer"
Thank you!
I haven't changed it. it's still the same. All Chinese characters have become?
Two fewer"
Thank you!
I haven't changed it. it's still the same. All Chinese characters have become?
Two fewer"
Thank you!
I haven't changed it. it's still the same. All Chinese characters have become?
Sorry, I made a mistake! This is because the header code has been written in the configuration file for a long time. I just read it!
Header ("Content-Type: text/html; charset = utf-8"); // This should be written in the header of the PHP file.
Two fewer"
Thank you!
I haven't changed it. it's still the same. All Chinese characters have become?
Two fewer"
Thank you!
I haven't changed it. it's still the same. All Chinese characters have become?
Sorry, I made a mistake! This is because the header code has been written in the configuration file for a long time. I just read it!
Header ("Content-Type: text/html; charset = utf-8"); // This should be written in the header of the PHP file.
Thank you. Is the php header written in front of the entire file?
Does it work if I write it below?
Header ('content-type: text/html; charset = UTF-8 ');
?>
Echo "my first PHP script! ";
?>
In addition, these php files run normally on the apache server and can display Chinese characters.
I think there is something wrong with the settings on the server. Please kindly advise me!
There is a major discovery. I use DW to generate a new php to display Chinese characters.
Previously, I used the code written on a WordPad, but I couldn't do it. open it in DW again. see if the content generated by DW is copied to the old file for storage or garbled characters.
There is a solution, but it won't work if it is written for the Mao wordboard?