PHP advanced object construction-use of the factory model _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.