class KnivesModel {
private $db;
public function __construct($dsn, $user, $pass){
try{
$this->$db = new PDO($dsn, $user, $pass);
}catch(PDOException $e){
var_dump($e);
} // <<< Right here
} // <<< Right here
}
Remove the ; at the end of the constructor declaration and try/catch block:
class KnivesModel {
private $db;
public function __construct($dsn, $user, $pass){
try{
$this->$db = new PDO($dsn, $user, $pass);
}catch(PDOException $e){
var_dump($e);
} // <<< Right here
} // <<< Right here
}
发布评论
评论(2)
try catch
和__construct
函数末尾不应有;
。There should be no
;
at the end of thetry catch
and the__construct
function.删除构造函数声明末尾的
;
和try/catch
块:Remove the
;
at the end of the constructor declaration andtry/catch
block: