Home > Backend Development > PHP Tutorial > PHP Advanced Object Construction - Use of Factory Pattern_PHP Tutorial

PHP Advanced Object Construction - Use of Factory Pattern_PHP Tutorial

WBOY
Release: 2016-07-13 17:48:50
Original
821 people have browsed it

abstract class prmodel {// Product model
abstract function link();
}

Class Weblink Extends PRMODEL {// Example A product
Public function link(){
echo "www.2cto.com
}  
}

class gongchang {                                                                                                                                                                           static public function createLink (){
          return new webLink();
}  
}
 
$weblink=gongchang::createLink(); //Create an object through the factory
$weblink->link(); //Output www.xxx.com
?>

Excerpted from chaojie2009’s column

http://www.bkjia.com/PHPjc/478392.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478392.htmlTechArticle?php abstract class prModel { //Product model abstract function link(); } class webLink extends prModel{ // Instance a product public function link(){ echo www.2cto.com } } class gong...
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