Last active
April 13, 2019 00:26
-
-
Save msato0731/979351cd2657037bd6735b3d5ad3b74b to your computer and use it in GitHub Desktop.
docker lamp pdo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DB_HOST', 'localhost'); | |
define('DB_USER', 'root'); | |
define('DB_PASSWORD', 'secret'); | |
define('DB_NAME', 'shop'); | |
try { | |
$dsn = 'mysql:host='.DB_HOST.'; dbname='.DB_NAME.';charset=utf8;'; | |
$pdo = new PDO($dsn, DB_USER, DB_PASSWORD); | |
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
print('接続しました。'); | |
} | |
catch(PDOException $e){ | |
print('ERROR:'.$e->getMessage()); | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment