self类本身

来源:互联网 发布:广联达破解软件下载 编辑:程序博客网 时间:2024/06/05 02:42
<?php //self类本身class Ad{public $rand;static public $ob=null;final protected function __construct(){$this->rand=mt_rand(1000000000,99999999999);}static public function getins(){//对外开放一个接口if (self::$ob===null){//让其对象只new一次self::$ob=new self();}return  self::$ob;}}var_dump(Ad::getins()); ?>

原创粉丝点击