Solve the problem of garbled Chinese characters in php

不言
Release: 2023-03-23 19:46:01
Original
5169 people have browsed it

The content of this article is about solving the problem of Chinese garbled characters in PHP. It has certain reference value. Friends in need can refer to it.

We are writing PHP code as follows:

<?php
$sum=0;
$total=1.2;
$sum=$total;
echo gettype($sum);
echo &#39;</br>&#39;;
$sum1=0;
$total1=$sum;
echo gettype($total1);//获取变量的类型
$sum3=100;
echo &#39;</br>&#39;;
settype($sum,"string");//设置变量的类型
echo gettype($sum3);
echo &#39;</br>&#39;;
echo &#39;判断一个变量是否存在:&#39;;
$a=5;
echo isset($a);
?>
Copy after login
When

, we will find that the php garbled

appears as follows:

double
double
integer
鍒ゆ柇涓€涓彉Read委槸钖﹀瓨鍦�: 1

This is originally Chinese ''To determine whether a variable exists: 1'

How to solve it?


The method is very simple, add

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

to the code as follows:

';
$sum1=0;
$total1=$sum;
echo gettype($total1);//获取变量的类型
$sum3=100;
echo '
'; settype($sum,"string");//设置变量的类型 echo gettype($sum3); echo '
'; echo '判断一个变量是否存在:'; $a=5; echo isset($a); ?>
Copy after login



The above is the detailed content of Solve the problem of garbled Chinese characters in php. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!