Home  >  Article  >  Backend Development  >  What to do if the Chinese garbled text in the php prompt box pops up?

What to do if the Chinese garbled text in the php prompt box pops up?

藏色散人
藏色散人Original
2021-07-02 09:25:561467browse

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");".

What to do if the Chinese garbled text in the php prompt box pops up?

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(&#39;Location: http://www.example.com/&#39;);
?>

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!

Statement:
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