Jump to content


Photo

virtual function in PHP?


  • Please log in to reply
4 replies to this topic

#1 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 24 May 2006 - 03:29 AM


class c1
{
virtual function func1();

}

class c2 extends c1
{
function func1()
{
// actual works done here
}

}

Is this kind of structure possible in PHP?

Life's too short for arguing.

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 May 2006 - 05:09 AM

Yes.

#3 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 24 May 2006 - 05:55 AM

[!--quoteo(post=376569:date=May 24 2006, 03:09 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 24 2006, 03:09 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Yes.
[/quote]

How, would be great.
Life's too short for arguing.

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 May 2006 - 06:31 AM

If I understand where your going... something like....
abstract class1 {
  public abstract function foo() {}
}

class2 impliments class1 {
  public function foo() {
    return true;
  }
}


#5 hvle

hvle
  • Members
  • PipPipPip
  • Advanced Member
  • 667 posts
  • Locationmelbourne, Australia

Posted 24 May 2006 - 07:19 AM

[!--quoteo(post=376586:date=May 24 2006, 04:31 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ May 24 2006, 04:31 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If I understand where your going... something like....
abstract class1 {
  public abstract function foo() {}
}

class2 impliments class1 {
  public function foo() {
    return true;
  }
}
[/quote]


strangely, I couldn't find any information relate to 'abstract' in the manual. There is very vague documentaion of class and OOP in PHP manual. I've found an alternative to this problem, but thanks for the info. I hope there'll be more 'doc' on this issue in the next version.


Life's too short for arguing.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users