Home >Backend Development >PHP Problem >What to do if php outputs garbled characters to the browser

What to do if php outputs garbled characters to the browser

藏色散人
藏色散人Original
2023-01-20 09:15:483615browse

Solution to garbled php output to the browser: 1. Open the corresponding php file; 2. Add "header('Content-Type: text/html; charset=utf- 8');" statement is enough.

What to do if php outputs garbled characters to the browser

The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer

How to output garbled characters to the browser manage?

The PHP file is garbled when opened with a browser

When writing web pages in PHP, I found that using PHP When the file is opened in the browser, it is all garbled, like this:

What to do if php outputs garbled characters to the browser

What to do if php outputs garbled characters to the browser

Looking for online information, I found that adding header('Content-Type: text/html;charset=utf-8'); Just fine,

The reason is that the encoding parsed by the browser is inconsistent with PHP.

This sentence tells the browser to use utf- 8 Encoding parsing PHP return data.

## Recommended study: "

PHP Video Tutorial"

The above is the detailed content of What to do if php outputs garbled characters to the browser. 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