The solution to the garbled Chinese characters in the php prompt box is to add an encoding output statement in front of the alert as "header("Content-Type: text/html;charset=utf-8");".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if the Chinese garbled prompt box pops up in php?
Garbled characters appear in the PHP alert prompt box?
Solution:
Add a sentence in front of the alert to encode the output
header("Content-Type:text/html;charset=utf-8");
or add this sentence at the top.
Related introduction:
The header() function sends the original HTTP header to the client.
It's important to realize that the header() function must be called before any actual output is sent (in PHP 4 and above, you can use output caching to solve this problem):
<html> <?php // 结果出错 // 在调用 header() 之前已存在输出 header('Location: http://www.example.com/'); ?>
Grammar
header(string,replace,http_response_code)
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if the Chinese garbled text in the php prompt box pops up?. For more information, please follow other related articles on the PHP Chinese website!