FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Why is polymorphism in PHP not like other languages? Is there a bug in PHP?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Why is polymorphism in PHP not like other languages? Is there a bug in PHP? [message #185027 is a reply to message #185026] Mon, 24 February 2014 21:16 Go to previous messageGo to previous message
kurtk(at)pobox(dot)com is currently offline  kurtk(at)pobox(dot)com
Messages: 10
Registered: May 2012
Karma:
Junior Member
Evidently, PHP just works differently. Even though Quackologist::update(\SplSubject) takes a reference to \SplSubject, this fine provide you pass (at runtime) a class derived from SplSubject that implements whoami(). Only if were to pass an SplSubject instance that does not implement whoami() will you get an runtime error.

C++, on the other hand, would complain

error: no member named 'whoami' in 'Base'

because Base has no whoami() method.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Completely stumped
Next Topic: Correlating curl resources to some other object.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 21:53:20 GMT 2024

Total time taken to generate the page: 0.04046 seconds