abstract:class Db{ //私有化构造方法 private function __construct() { } //私有化克隆方法 private function __clone() { &n
class Db{
//私有化构造方法
private function __construct()
{
}
//私有化克隆方法
private function __clone()
{
// TODO: Implement __clone() method.
}
protected static $db;
//内部实例化方法
public static function dbInstant($host,$user,$password,$dbname){
if(isset(self::$db)){
return self::$db;
}else{
return self::$db=new PDO("mysql:".$host.";".$dbname,$user,$password);
}
}
}
$db = Db::dbInstant('127.0.0.1','root','root','ceshi');
Correcting teacher:查无此人Correction time:2019-05-13 09:36:04
Teacher's summary:完成的不错。编程还有很多模式。多了解,可以更好的提高能力。继续加油