Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official




Recommended Posts

一般情况下我们的网页代码集采用utf-8,php返回的错误信息的中文编码是GBK,就会导致无法正确显示中文的问题,这是我们可以用mb_convert_encoding($原字符串, "目标便编码","原编码")将返回信息的编码变成utf-8,这样就可以正常显示中文了。

 1 <?php 
 2 header("Content-type: text/html; charset=utf-8");
 4 $db_host='localhost33';  
 5 $db_user='root';
 6 $db_pass='root';
 7 $db_name='test';
 8 $db_table='keji';
 9 if(!$link=mysqli_connect($db_host,$db_user,$db_pass)){
11     $contents = mb_convert_encoding(mysqli_connect_error(),"utf-8","gbk");
12     echo '错误:'. $contents;
13     exit();
14 }
16 var_dump($link);
18 if(!mysqli_connect($link,$db_name)){
19     echo "打开{$db_name}失败!";
20     exit();
21 }
22 // $sql='select * from keji;'
23 mysqli_close($link);
26 ?>
Link to post
Link to comment
Share on other sites


discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    • Create New...