mysqli::character_set_name

mysqli_character_set_name

(PHP 5, PHP 7)

mysqli::character_set_name -- mysqli_character_set_name锟斤拷锟截碉拷前锟斤拷锟捷匡拷锟斤拷锟接碉拷默锟斤拷锟街凤拷锟斤拷锟斤拷

说锟斤拷

锟斤拷锟斤拷锟斤拷锟斤拷锟�

mysqli::character_set_name ( void ) : string

锟斤拷锟教伙拷锟斤拷锟�

mysqli_character_set_name ( mysqli $link ) : string

锟斤拷锟截碉拷前锟斤拷锟捷匡拷锟斤拷锟接碉拷默锟斤拷锟街凤拷锟斤拷锟诫。

锟斤拷锟斤拷

link

锟斤拷锟皆癸拷锟教伙拷锟斤拷式锟斤拷锟斤拷mysqli_connect() 锟斤拷 mysqli_init() 锟斤拷锟截碉拷锟斤拷锟接憋拷识锟斤拷

锟斤拷锟斤拷值

The default character set for the current connection

锟斤拷锟斤拷

Example #1 mysqli::character_set_name() example

锟斤拷锟斤拷锟斤拷锟斤拷锟�

<?php
/* Open a connection */
$mysqli = new mysqli("localhost""my_user""my_password""world");

/* check connection */
if (mysqli_connect_errno()) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* Print current character set */
$charset $mysqli->character_set_name();
printf ("Current character set is %s\n"$charset);

$mysqli->close();
?>

锟斤拷锟教伙拷锟斤拷锟�

<?php
/* Open a connection */
$link mysqli_connect("localhost""my_user""my_password""world");

/* check connection */
if (!$link) {
    
printf("Connect failed: %s\n"mysqli_connect_error());
    exit();
}

/* Print current character set */
$charset mysqli_character_set_name($link);
printf ("Current character set is %s\n",$charset);

/* close connection */
mysqli_close($link);
?>

锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�

Current character set is latin1_swedish_ci

锟轿硷拷

  • mysqli_set_charset() - 锟斤拷锟斤拷默锟斤拷锟街凤拷锟斤拷锟斤拷
  • mysqli_client_encoding() - mysqli_character_set_name 锟侥憋拷锟斤拷
  • mysqli_real_escape_string() - 锟斤拷锟捷碉拷前锟斤拷锟接碉拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷 SQL 锟斤拷锟斤拷械锟斤拷锟斤拷锟斤拷址锟斤拷锟斤拷锟阶拷锟�