인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

nak512님의 프로필 이미지
nak512

작성한 질문수

PHP 7+ 프로그래밍

55 - 인증 (Auth; Login, Logout), 유저 (User; Update)

mysqli_stmt_close($stmt) 관련 질문드립니다.

작성

·

247

0

안녕하세요 선생님, update_process.php 를 작성하던 중

    if(mysqli_stmt_execute($stmt)) {
        session_unset();
        session_destroy();
        mysqli_stmt_close($stmt);
        return header('Location:/auth/login.php');
    } else {
        return header('Location: /user/register.php');
    }
    return mysqli_stmt_close($stmt);

다음과 같이 작성하시는 것을 보게 되었는데요,
위와 같이 작성하면 

mysqli_stmt_execute($stmt)를 실행한 결과가 true 던지
false 던지 return을 해버려서 뒤에 

return mysqli_stmt_close($stmt); 을 실행하지 못하고 종료하게 되는것이 아닌지요?


답변 1

0

정상우님의 프로필 이미지
정상우
지식공유자

안녕하세요.
예제코드를 찾아보니 그 부분은 강의를 업로드 한 이후에 수정되어 있는 것을 봐선 제 실수인듯 싶습니다.

눈썰미가 좋으시군요! :))

if (mysqli_execute($stmt)) {
    session_unset();
    session_destroy();
    header('Location: /auth/login.php');
} else {
    header('Location: /user/update.php');
}
return mysqli_stmt_close($stmt);
nak512님의 프로필 이미지
nak512
질문자

항상 빠르고 자세한 답변에 감사드립니다. 오늘 하루도 좋은 하루 되세요!

nak512님의 프로필 이미지
nak512

작성한 질문수

질문하기