时间:2021-07-01 10:21:17 帮助过:10人阅读
输出www.chhua.com
<?php
class Registry {
private static $instance;
private $request;//注册表的内容类
private function __construct(){}//本类,不可实例化
static function instance(){//单例类,通过这个方法返回实例
if (!isset(self::$instance)){self::$instance=new self();}
return self::$instance;
}
function getRequest(){//返回注册的内容类
return $this->request;
}
function setRequest(request $request){//设置注册的内容类
$this->request=$request;
}
}
class request{//被 注册的类
private $webname="WEB开发笔记";
private $url="www.chhua.com";
function getName(){
echo $this->url;//