mysqli::$connect_errno

(PHP 5, PHP 7, PHP 8)

mysqli::$connect_errno -- mysqli_connect_errno — 마지막 연결 호출의 오류 코드를 반환합니다.


설명

객체 지향 스타일

int $mysqli->connect_errno;

절차적 스타일

mysqli_connect_errno(): int

마지막 연결 시도의 오류 코드를 반환합니다.


매개변수

이 함수에는 매개변수가 없습니다.


반환 값

실패한 경우 마지막 연결 시도에 대한 오류 코드입니다. 0은 오류가 발생하지 않았음을 의미합니다.


Examples

예제 #1 $mysqli->connect_errno 예제

객체 지향 스타일

                  
<?php
/* @ is used to suppress default error messages */
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');

if ($mysqli->connect_errno) {
    /* Use your preferred error logging method here */
    error_log('Connection error: ' . $mysqli->connect_errno);
}
                  
                

절차적 스타일

                  
<?php
/* @ is used to suppress default error messages */
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');

if (!$link) {
    /* Use your preferred error logging method here */
    error_log('Connection error: ' . mysqli_connect_errno());
}
                  
                

위의 예는 다음을 출력합니다.

Connection error: 1045
                

기타