pdo 抽象层连接数据库

时间:2023-03-10 05:19:30
pdo 抽象层连接数据库

<?php
  header("content-type:text/html; charset=utf8");
 
  try{
      
    $pdo=new PDO('mysql:host=localhost;dbname=test', "root", "");
    
    
    
  }catch(PDOException $e){
      
    echo "连接失败".$e->getMessage();
    exit;
    
    
  }
  echo "创建成功";