Home  >  Article  >  Backend Development  >  Solution to garbled php page

Solution to garbled php page

藏色散人
藏色散人Original
2020-11-04 09:17:103647browse

Solution to garbled php page: 1. Set the text encoding displayed on the page through "header("Content-Type:text/html;charset=utf-8");"; 2. Through "mysqli_set_charset" Set the default client character set.

Solution to garbled php page

Recommended: "PHP Video Tutorial"

php: Solution to garbled pages

in

<?php
header("Content-Type:text/html;charset=utf-8");   ////设置页面显示的文字编码          头部就写header函数处理成utf-8
//链接数据库
$con = mysqli_connect(&#39;127.0.0.1&#39;, &#39;root&#39;, &#39;123456&#39;, &#39;test&#39;); 本地地址 数据库登录名  登录密码  数据库名
mysqli_set_charset($con,"utf8");//设置默认客户端字符集。 数据库链接好后紧接着就设置字符集
?>

The above is the detailed content of Solution to garbled php page. 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