Graduation project ppt format PHP design pattern registry pattern

WBOY
Release: 2016-07-29 08:47:55
Original
1044 people have browsed it

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 function of the registry is to provide system-level object access functions.

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!