©
Ce document utilise Manuel du site Web PHP chinois Libérer
(PHP 5)
mysqli::character_set_name -- mysqli_character_set_name — 返回当前数据库连接的默认字符编码
面向对象风格
过程化风格
$link
)返回当前数据库连接的默认字符编码。
link
仅以过程化样式:由 mysqli_connect() 或 mysqli_init() 返回的链接标识。
The default character set for the current connection
Example #1 mysqli::character_set_name() example
面向对象风格
<?php
$mysqli = new mysqli ( "localhost" , "my_user" , "my_password" , "world" );
if ( mysqli_connect_errno ()) {
printf ( "Connect failed: %s\n" , mysqli_connect_error ());
exit();
}
$charset = $mysqli -> character_set_name ();
printf ( "Current character set is %s\n" , $charset );
$mysqli -> close ();
?>
过程化风格
<?php
$link = mysqli_connect ( "localhost" , "my_user" , "my_password" , "world" );
if (! $link ) {
printf ( "Connect failed: %s\n" , mysqli_connect_error ());
exit();
}
$charset = mysqli_character_set_name ( $link );
printf ( "Current character set is %s\n" , $charset );
mysqli_close ( $link );
?>
以上例程会输出:
Current character set is latin1_swedish_ci