mysqli::character_set_name
mysqli::character_set_name
mysqli_character_set_name
(PHP 5, PHP 7)
mysqli :: character_set_name - mysqli_character_set_name - 返回数据库连接的默认字符集
Description
面向对象的风格
string mysqli::character_set_name ( void )
程序风格
string mysqli_character_set_name ( mysqli $link )
返回数据库连接的当前字符集。
Parameters
`link`
仅过程样式:由mysqli_connect()或mysqli_init()返回的链接标识符
Return Values
当前连接的默认字符集
Examples
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
© 1997–2017 The PHP Documentation Group
根据知识共享署名许可证v3.0或更高版本授权。