Wrox Programmer Forums
|
BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1
This is the forum to discuss the Wrox book Professional PHP5 by Ed Lecky-Thompson, Heow Eide-Goodman, Steven D. Nowicki, Alec Cove; ISBN: 9780764572821
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 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 February 8th, 2005, 08:11 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Norm 2782
Default [CH04] Interfaces

I just got to chapter 4 and got to the abstract_widget.php file.
It returned the following error:

Fatal error: Declaration of Widget::update() must be compatible with that of Observer::update() in C:\server\www\prophp\ch04\abstract_widget.php on line 6

I solved it by replacing the interface used in the example by the following one:

Code:
interface Observer {
    public function update(Observable $observable);
}
Is this 'legit' user of interfaces? Or is this a dirty solution to a (maybe very simple) problem?

Norm 2782, why are you here?
- Normality
 
Old May 30th, 2005, 01:04 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tnlinh
Default

I encountered the same problem and did exactly the same.

 
Old June 15th, 2005, 08:13 PM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yep, another one. Good one Norm2782.
I still don't see the benefit of this example or pattern for a web application. Anyone?

Nice Widgets, but that's about it.

As stated on p. 85, a redraw is not an option unless you reload the page.... so why putting Observers on data?
 
Old June 16th, 2005, 04:56 AM
Registered User
 
Join Date: Jun 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

can someone please clarify whether or not the previous example is a valid use for interfaces or not?

I had the same problem in chapter two!!

Code:
interface Musician {
     public function addInstrument();
     public function getInstruments();

     public function assignToBand();
     public function getMusicianType();
  }
Gave me this error
Fatal error: Declaration of Guitarist::addInstrument() must be compatible with that of Musician::addInstrument()

Code:
interface Musician {
     public function addInstrument(Instrument $instument);
     public function getInstruments();

     public function assignToBand(Band $band);
     public function getMusicianType();
  }
Seems to work

Is this correct ??

Thank

Sam






Similar Threads
Thread Thread Starter Forum Replies Last Post
returning interfaces mike72 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 April 17th, 2008 05:53 AM
interfaces malli_kv2 Java Basics 1 April 23rd, 2007 05:21 AM
Ch04 TIO Pg 111 Error lollivier BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 4 February 14th, 2006 11:31 AM
Polymorphism with Interfaces digby_dog VB.NET 2002/2003 Basics 2 May 11th, 2005 12:50 PM





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