Пример #1
0
    function __construct($title_in, $author_in)
    {
        $this->author = $author_in;
        $this->title = $title_in;
    }
    function getAuthor()
    {
        return $this->author;
    }
    function getTitle()
    {
        return $this->title;
    }
    function getAuthorAndTitle()
    {
        return $this->getTitle() . ' by ' . $this->getAuthor();
    }
}
define('BR', '<' . 'BR' . '>');
echo 'BEGIN TESTING TEMPLATE PATTERN' . BR;
echo BR;
$book = new Book('PHP for Cats', 'Larry Truett');
$exclaimTemplate = new TemplateExclaim();
$starsTemplate = new TemplateStars();
echo 'test 1 - show exclaim template' . BR;
echo $exclaimTemplate->showBookTitleInfo($book);
echo BR . BR;
echo 'test 2 - show stars template' . BR;
echo $starsTemplate->showBookTitleInfo($book);
echo BR . BR;
echo 'END TESTING TEMPLATE PATTERN' . BR;
Пример #2
0
        $this->title = $title_in;
    }
    function getAuthor()
    {
        return $this->author;
    }
    function getTitle()
    {
        return $this->title;
    }
    function getAuthorAndTitle()
    {
        return $this->getTitle() . ' by ' . $this->getAuthor();
    }
}
writeln('BEGIN TESTING TEMPLATE PATTERN');
writeln('');
$book = new Book('PHP for Cats', 'Larry Truett');
$exclaimTemplate = new TemplateExclaim();
$starsTemplate = new TemplateStars();
writeln('test 1 - show exclaim template');
writeln($exclaimTemplate->showBookTitleInfo($book));
writeln('');
writeln('test 2 - show stars template');
writeln($starsTemplate->showBookTitleInfo($book));
writeln('');
writeln('END TESTING TEMPLATE PATTERN');
function writeln($line_in)
{
    echo $line_in . "<br/>";
}