Set the default client character set in PHP

Description

The following code shows how to set the default client character set.

Example


  // ww  w.j a  va2s  .  co m
<?php
     $con=mysqli_connect("localhost","root","","test");
     // Check connection
     if (mysqli_connect_errno()){
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
     }
   
     // Change character set to utf8
     mysqli_set_charset($con,"utf8");
   
     mysqli_close($con);
?>




















Home »
  PHP Tutorial »
    MySQL »




MySQLi
MySQLi Object Oriented