Home > php教程 > php手册 > PHP高级对象构建工厂模式的使用

PHP高级对象构建工厂模式的使用

WBOY
Release: 2016-06-13 10:47:19
Original
1025 people have browsed it

abstract class prModel {                             //产品模型 
    abstract function link(); 

  
class webLink extends prModel{                      //实例一个产品 
    public function link(){ 
        echo "www.2cto.com
    } 

  
class gongchang {                                  //工厂 
    static public function createLink (){ 
        return new webLink(); 
    } 

   
$weblink=gongchang::createLink();                 //通过工厂制造一个对象 
$weblink->link();                                 //输出www.xxx.com
?> 

摘自 chaojie2009的专栏

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template