abstract:<?php class Curl { public $pdo = ''; public function __construct(){//try拋出異常處理 try{ $this->pdo = new PDO("mysql:host=127.0.0.1;dbname=1604a",'root
<?php
class Curl
{
public $pdo = '';
public function __construct(){
//try拋出異常處理
try{
$this->pdo = new PDO("mysql:host=127.0.0.1;dbname=1604a",'root','root');
} catch (PDOException $e) {
echo $e->getMessage();
}
}
}
$mysqli = new Curl();
?>
Correcting teacher:韋小寶Correction time:2019-03-14 16:58:10
Teacher's summary:目前在PHP中使用最多連接數據庫的方式就是pdo 當然也有使用mysqli的 pdo可以連接任何類型的數據庫 使用起來也很方便簡單