在命名空間下的類,導入trait 如何實現單例模式實例化
<?php?
?//namespace traitname;
?include_once"trait.php";
?class lui{
? use? tu,one;
private static $cs=null;
? ? private function __constrouct(){
? ?
? }
private function __clone(){
}
? ? public? function qname($vname){
? ? $this->name=$vname;
}
public static function xinif(){
if(!(self::$cs instanceof self)){
self::$cs = new self();
}
return self::$cs;
}
}
?>
2021-06-18
一樣的, 和有沒有使用trait無關