English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
mysqli_get_charset() 함수가 문자셋 객체를 반환합니다
mysqli_get_charset()함수가 문자셋 클래스의 객체를 반환하며 다음 속성을 포함합니다:
charset: 문자셋의 이름.
collation: 정렬 규칙의 이름.
dir: 얻은 디렉토리 문자셋 또는 "".
min_length: 최소 문자 길이(바이트).
max_length: 최대 문자 길이(바이트).
number: 내부 문자셋 수.
state: 문자셋 상태.
mysqli_get_charset($con)
순번 | 파라미터 및 설명 |
---|---|
1 | con(필수) MySQL 서버와의 연결을 나타내는 객체입니다. |
mysqli_get_charset()함수가 반환하는 문자셋 클래스의 객체.
이 함수는 원래 PHP 버전5포함되어 있으며 모든 더 높은 버전에서 사용할 수 있습니다.
다음 예제에서는 설명됩니다mysqli_get_charset()함수의 사용 방법(과정 방식)-
<?php $db = mysqli_init(); //연결 수립 mysqli_real_connect($db, "localhost","root","password","test"); //자리셋 $res = mysqli_get_charset($db); print_r($res); ?>
출력 결과
stdClass Object ( [charset] => utf8 [collation] => utf8_general_ci [dir] => [min_length] => 1 [max_length] => 3 [number] => 33 [state] => 1 [comment] => UTF-8 Unicode )
객체 지향 스타일에서 이 함수의 문법은 다음과 같습니다$db->get_charset();.아래는 객체 지향 스타일에서 이 함수의 예제입니다;
<?php $db = mysqli_init(); //데이터베이스에 연결됨 $db->real_connect("localhost","root","password","test"); //문자 집합 이름 $res = $db->get_charset(); print_r($res); ?>
출력 결과
stdClass Object ( [charset] => utf8 [collation] => utf8_general_ci [dir] => [min_length] => 1 [max_length] => 3 [number] => 33 [state] => 1 [comment] => UTF-8 Unicode )
속성을 가진 문자 집합 객체와 기본 문자 집합을 반환합니다:
<?php $connection_mysql = mysqli_connect("localhost","root","password","mydb"); if (mysqli_connect_errno($connection_mysql)){ echo "MySQL 연결 실패: " . mysqli_connect_error(); } var_dump(mysqli_get_charset($connection_mysql)); mysqli_close($connection_mysql); ?>
출력 결과
object(stdClass)#2 (8) { ["charset"]=> string(4) "utf8" ["collation"]=> string(15) "utf8_general_ci" ["dir"]=> string(0) "" ["min_length"]=> int(1) ["max_length"]=> int(3) ["number"]=> int(33) ["state"]=> int(1) ["comment"]=> string(13) "UTF-8 Unicode" } 기본 문자 집합은: utf8