try catch php 捕获,php try catch : 捕捉异常,抛出异常
php try catch : 捕捉異常,拋出異常:/**
* 構造函數:自動加載連接數據庫
* @param $database $key
* @return
*/
private function __construct($database = array(), $key){
try{
$this->server = $database['db_host'];
$this->username = $database['db_user'];
$this->password = $database['db_pwd'];
$this->database_name = $database['db_name'];
$this->database_type = $database['db_type'];
$this->database_port = $database['db_port'];
if($this->database_type == 'mysql'){
$this->pdo = new PDO($this->database_type . ':host=' .
$this->server . ';port=' .
$this->database_port . ';dbname=' .
$this->database_name,
$this->username,
$this->password, array(PDO::ATTR_TIMEOUT => self::TIME_OUT));
}else{
$this->pdo = new PDO ("dblib:host=$this->server:$this->database_port;
dbname=$this->database_name","$this->username","$this->password");
}
$this->pdo->exec('SET NAMES \'' . $this->charset . '\'');
self::$pdo_ref[$key] = &$this->pdo;
}catch(PDOException $e){
echo $e->getMessage();
}
}
以上就介紹了php try catch : 捕捉異常,拋出異常,包括了方面的內容,更多相關內容請關注PHP中文網(www.php.cn)!
本文原創發布php中文網,轉載請注明出處,感謝您的尊重!
總結
以上是生活随笔為你收集整理的try catch php 捕获,php try catch : 捕捉异常,抛出异常的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python编写抢座位软件_程序员硬核P
- 下一篇: java竖线分割_Java String