LoginSignup
6
6

More than 5 years have passed since last update.

PDOでMySQL文字コード設定

Posted at

PHP / PDO で MySQL接続時に文字コードを設定する

pdo_utf8.php
try {
    $pdo = new PDO($db_dsn,$db_user, $db_password,
        array(
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET CHARACTER SET `utf8`"
        )
    );
} catch (PDOException $e) {
    die($e->getMessage());
}
6
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6