What to do if php output array is garbled

藏色散人
Release: 2023-03-17 16:48:02
Original
4254 people have browsed it

Solution to garbled php output array: 1. Open the corresponding php file; 2. Check whether the encoding is set; 3. Add "header("Content-type:text/html;charset= at the beginning of the file utf-8 ");" statement is enough.

What to do if php output array is garbled

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

#What should I do if the output array of php is garbled?

Solution to Chinese garbled characters:

header("Content-type:text/html;charset=utf-8");
Copy after login

For example:

Use print_r() to output an array

The print_r() function is used to Print variables in a more understandable form. The print_r() function can output the contents and structure of the entire array, and the keys and elements will be displayed in a certain format.

"张三","年龄"=>25,"性别"=>"男"),
    array("姓名"=>"李四","年龄"=>21,"性别"=>"男"),
    array("姓名"=>"娜娜","年龄"=>22,"性别"=>"女")
);
 print_r($array);
?>
Copy after login

Output:

What to do if php output array is garbled

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What to do if php output array is garbled. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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