Php displays question marks in the browser. how can this problem be solved?
Source: Internet
Author: User
What should I do if php displays question marks in Chinese in the browser? If I try it on Windows 7, this will happen on mac. I suspect it is a problem with apache or php settings on mac. The source file code contains Chinese characters, but the Chinese characters are unavailable when you use a browser to view the source code. What should I do ?, That is, php file encoding and database (if the garbled text is queried in the database) encoding are inconsistent with the encoding declared in html code. what should I do if php displays a question mark in the browser?
If I try it on Windows 7, this will happen on mac. I suspect it is a problem with apache or php settings on mac. The source file code contains Chinese characters, but the Chinese characters are unavailable when you use a browser to view the source code. What should I do?
------ Solution --------------------
Php file encoding and database encoding (if garbled text is found in the database) are inconsistent with the encoding declared in html code. one of the first two is not UTF-8 encoded.
------ Solution --------------------
Then you look at the php file itself is UTF-8, and then look at the page opened, Web code whether to choose the corresponding UTF-8 encoding
------ Solution --------------------
The PHP file must be UTF-8 encoded. Are you sure you want?
------ Solution --------------------
Discussion
Reference:
It's also a garbled problem ......
Reference:
For garbled characters, check whether the following codes are consistent:
Encoding used by the database
Encoding used for database operations
Encoding used on the current page
File encoding
If they are consistent, there will be no problem.
`
------ Solution --------------------
Mysql databases, php files, and php files must be completed.
Correct settings:
For example, all are UTF-8
Set mysql database to utf8 unicode,
Php header:
The most important thing is that the php file is UTF-8 encoded. the default value is ansi.
Method: Open the php file in Notepad and save it as UTF-8.
OK!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service