Home > Article > Backend Development > Solve the problem of garbled Chinese characters in php
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 '</br>'; $sum1=0; $total1=$sum; echo gettype($total1);//获取变量的类型 $sum3=100; echo '</br>'; settype($sum,"string");//设置变量的类型 echo gettype($sum3); echo '</br>'; echo '判断一个变量是否存在:'; $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!