Copy CodeThe code is as follows:
<?php
/**
* Template mode
*
* Define an algorithm skeleton in an operation, and delay some steps into subclasses so that subclasses can define certain steps of the algorithm without altering the structure of an algorithm
*
*/
Abstract class Templatebase
{
Public Function Method1 ()
{
echo "Abstract method1<br/>";
}
Public Function Method2 ()
{
echo "Abstract method2<br/>";
}
Public Function Method3 ()
{
echo "Abstract method3<br/>";
}
Public Function dosomething ()
{
$this->method1 ();
$this->method2 ();
$this->method3 ();
}
}
Class Templateobject extends Templatebase
{
}
Class TemplateObject1 extends Templatebase
{
Public Function Method3 ()
{
echo "TemplateObject1 method3<br/>";
}
}
Class TemplateObject2 extends Templatebase
{
Public Function Method2 ()
{
echo "TemplateObject2 method2<br/>";
}
}
Instantiation of
$objTemplate = new Templateobject ();
$objTemplate 1 = new TemplateObject1 ();
$objTemplate 2 = new TemplateObject2 ();
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