Home  >  Article  >  Backend Development  >  Solve the problem of garbled Chinese characters in php

Solve the problem of garbled Chinese characters in php

不言
不言Original
2018-04-14 10:42:025125browse

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);
?>
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");

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); ?>



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!

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