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

藏色散人
Release: 2023-03-11 07:22:02
Original
1486 people have browsed it

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");
Copy after login

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;);
?>
Copy after login

Grammar

header(string,replace,http_response_code)
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template