Blogger Information
Blog 48
fans 0
comment 0
visits 36372
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
pdo数据库连接-2018.08.30
雨天的博客
Original
560 people have browsed it

实例

<?php
/**
 * pdo:是php操作所有数据库的抽象层,提供了一个统一的访问接口
 *
 */
//dsn 数据源,设置数据库的类型,以及数据库服务器和默认的数据库;
$dsn = 'mysql:host=127.0.0.1;$dbname=php';
$user = 'root';
$password = 'root';
try{
    $pdo = new PDO($dsn,$user,$password);
    echo '<h3>数据库连接成功</h3>';
}catch (PDOException $e)
{
    exit('connect error'.$e->getMessage());
}
$pdo = null;

运行实例 »

点击 "运行实例" 按钮查看在线实例


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!