Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 21st, 2010, 04:52 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Question PHP Design Pattern - interface (from Zend Cert)

I am currently studying towards my Zend PHP certification and have came across this question in my first practice exam:

Consider the following series of classes and interfaces

Code:
<?php
interface MyInterface {
public function getTitleAndAuthor();
}

class MyClass {

private $_author;
private $_title;

public function getAuthor() {
return $this->_author;
}

public function getTitle() {
return $this->_title;
}
}

class MyClass2 {

private $_instance;

public function __construct(MyClass $a) {
$this->_instance = $a;
}

public function getTitleAndAuthor() {
$retval = array(
'title' => $this->_instance->getTitle(),
'author' => $this->_instance->getAuthor()
);
return $retval;
}
}

class MyClass3 {
public function doSomething(MyInterface $instance) {
$value = $instance->getTitleAndAuthor();
}
}

?>
Can anyone advise - MyClass2 is an example of the what design pattern, and why?

Best Regards,
Picco
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cutting Edge User Interface Design? MrBaseball34 .NET Framework 3.5 5 December 15th, 2009 07:16 PM
Object Design Pattern problem aldwinenriquez .NET Framework 2.0 2 September 7th, 2006 04:10 AM
design pattern kishore.dyn Struts 1 February 14th, 2006 02:36 PM
PHP Pattern Matching joanncae BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 May 17th, 2004 04:52 PM
ASP.NET Design interface bmains VS.NET 2002/2003 4 April 9th, 2004 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.