PHP advanced object building-use of the factory model .? PhpabstractclassprModel {product model abstractfunctionlink ();} classwebLinkextendsprModel {instance a product publicfunctionlink () {echowww.2cto.com} classgong Abstract class prModel {// product model
Abstract function link ();
}
Class webLink extends prModel {// instance a product
Public function link (){
Echo "www.2cto.com
}
}
Class gongchang {// factory
Static public function createLink (){
Return new webLink ();
}
}
$ Weblink = gongchang: createLink (); // create an object through a factory
$ Weblink-> link (); // outputs www.xxx.com
?>
From chaojie2009
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...