To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Upgrading PHP

Upgrading PHP Issues concerning PHP version upgrades and future releases

Reply
 
Thread Tools Rate Thread Display Modes
Old 09-04-2004, 11:05 PM   #1
kkobashi
Senior Member
 
kkobashi's Avatar
 
Join Date: Aug 2004
Location: Silicon Valley, CA
Posts: 273
Interfaces and Inheritence

Under PHP5:

Can a class implement more than one interface:

class SomeClass implements Interface1, Interface2
{
}

Can a class implement AND extend another class?

class SomeClass extends AnotherClass implements Interface1
{
}

From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed.
__________________
Kerry Kobashi
Kobashi Computing
kkobashi is offline   Reply With Quote
Old 09-05-2004, 01:21 AM   #2
goldbug
50,000 Watts of Goodwill
 
goldbug's Avatar
 
Join Date: May 2003
Location: Rummaging through your garbage.
Posts: 1,326
Re: Interfaces and Inheritence

Quote:
Originally posted by kkobashi
Under PHP5:

Can a class implement more than one interface:

class SomeClass implements Interface1, Interface2
{
}
IIRC, I read somewhere that this was possible.... easiest way to find out is to try.

Quote:

Can a class implement AND extend another class?

class SomeClass extends AnotherClass implements Interface1
{
}

From my understanding, PHP5 does not allow multiple inheritance. Thus use of one of the techniques above is needed.
See previous note
__________________
Many eyes make few mistakes

goldendance
goldbug is offline   Reply With Quote
Old 09-09-2004, 10:58 AM   #3
Shrike
Not Yet Involved
 
Shrike's Avatar
 
Join Date: Oct 2003
Location: The Eighth, Sursamen
Posts: 2,254
PHP5 supports single inheritance and multiple implementations, at the same time.
PHP Code:
class bar extends foo implements moo, doo, boo {

}
Not sure what that has to do with multiple inheritance though?
__________________
The Hundredth Idiot
Shrike is offline   Reply With Quote
Old 09-11-2004, 10:10 AM   #4
BSTRhino
BST: Hypertext Processor
 
BSTRhino's Avatar
 
Join Date: Oct 2003
Location: Christchurch, New Zealand
Posts: 36
kkobashi, you are right, PHP doesn't support multiple inheritance. I think you're confusing inheritance and interfaces. Interfaces are used to get around the multiple inheritance problem, which sometimes limits you from giving certain objects the functionality they need.

Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP.
__________________
Favourite forums: http://www.warboards.org/
My website: http://www.starcraft.org

Last edited by BSTRhino; 09-11-2004 at 10:12 AM.
BSTRhino is offline   Reply With Quote
Old 09-12-2004, 02:43 AM   #5
Weedpacket
Custom User Title™
 
Weedpacket's Avatar
 
Join Date: Aug 2002
Location: Rapid Offensive Unit "Foreign Object Damage"
Posts: 19,122
Quote:
Originally posted by BSTRhino
Interfaces are used heaps in Java. But to be honest, I can't think of a useful purpose for them in PHP.
You can if($object instanceof InterfaceName)

http://www.phpbuilder.com/board/show...eadid=10284617
__________________
On two occasions I have been asked [by Members of Parliament], "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
Weedpacket is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 03:03 PM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.