TypechoJoeTheme

至尊技术网

统计
登录
用户名
密码
/
注册
用户名
邮箱

悠悠楠杉

网站页面
搜索到 1 篇与 的结果
2020-12-29

PHP面向对象中的$this、self、parent

PHP面向对象中的$this、self、parent
<?php // $this 本对象 // self 本类 // parent 父类 class Single { public $rand; public static $ob; //final 方法不能被子类重写,实现单例模式 final protected function __construct() { $this->rand = mt_rand(1000, 9999); } public static function getins() { if (self::$ob == null) { self::$ob = new self(); } return self::$ob; } } var_dump(Single::getins()); class Par { public function __construct() { echo mt_rand(10000, ...
2020年12月29日
721 阅读
0 评论