Home >Backend Development >PHP Tutorial >Graduation project ppt format PHP design pattern registry pattern
The following is the code of the basic registry class:
Copy the code The code is as follows:
class Registry {
private static $instance;
private $request;//Content class of the registry
private function __construct(){}//This class cannot be instantiated
static function instance(){//Singleton class, return an instance through this method
if (!isset(self::$instance)){self: :$instance=new self();}
return self::$instance;
}
function getRequest(){//Return the registered content class
return $this->request;
}
function setRequest(request $ request){//Set the registered content class
$this->request=$request;
}
}
class request{//The registered class
private $webname="WEB Development Notes";
private $url ="www.chhua.com";
function getName(){
echo $this->url;//Output www.chhua.com
}
}//Registered empty class
//Use
$reg =Registry::instance();
$reg->setRequest(new request());
$request=$reg->getRequest();
$request->getName();//Output www. chhua.com
?>
The above has introduced the graduation project ppt format, PHP design mode and registry mode, including the contents of the graduation project ppt format. I hope it will be helpful to friends who are interested in PHP tutorials.