<?php
<?php
class sigle{
protected static $ins = null;
public static function getins(){
if(self::$ins === null){
self::$ins = new self();
}
return self::$ins;
}
//方法千家final 则方法不能被覆盖,类前加final则类不能被继承
final protected function __construct(){
}
//封锁克隆
final protected function __clone(){
}
}
$s1 = sigle::getins();
$s2 = clone $s1;//报错
本文来自博客园,作者:孙龙-程序员,转载请注明原文链接:https://www.cnblogs.com/sunlong88/p/8691478.html
浙公网安备 33010602011771号