header('Content-type:text/html;Charset=utf-8'); /** * 实例化PDO对象 */ // 1, 设置相关的参数 // 1.1 确定数据源 $dbms = 'mysql'; $host = 'localhost'; $port = '3306'; $dbname = 'jf'; $charset = 'utf8'; $dsn = "$dbms:host=$host;port=$port;dbname=$dbname;charset=$charset"; // 1.2 确定用户名和密码 $user = 'root'; $pass = '123456'; // 2, 实例化PDO类 $pdo = new PDO($dsn, $user, $pass); var_dump($pdo);