<?php
header("Content-Type: text/html; charset=UTF-8");
try{
// MySQL PDO 객체 생성
// mysql을 다른 DB로 변경하면 다른 DB도 사용 가능
$pdo = new PDO('mysql:host=localhost;dbname=homesi;charset=utf8','userId','userPw');
// 에러 출력
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
print "데이터 베이스 접속 성공";
}
catch(Exception $e) {
echo$e->getMessage();
}
?>
'PHP > 새로운문법' 카테고리의 다른 글
예외처리(try ~ catch) (0) | 2017.11.09 |
---|---|
간단한 로그인예제(Session) (0) | 2017.11.09 |
쿠키 (0) | 2017.11.08 |
난수생성 (0) | 2017.11.08 |
시간관련 함수 (0) | 2017.11.08 |