Stec Records Forum

Tools to make music

News: We are back.  We've updated the look of the forum with a new "theme" that works better on mobile devices. Also note that we check all new user requests for spam violations. If you believe you have been rejected unfairly please contact us and we will attempt to resolve it with you.  - Stecrew

Reference a base class function from within an override (Read 2671 times)

  • Administrator
  • Hero Member
  • Chief Administrator
  • Posts: 771
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
From Todd Sellon:
This is pretty easy to do.  Here is an example.

<?php
class A
{
   function A()
   {
   }
   function foo()
   {
      return "bar";
   }
}

class B extends A
{
   function B()
   {
      $this->A();
   }
   function foo()
   {
      return A::foo();
   }
}

$a = new B();

echo($a->foo()); // Output: bar

?>

I am not sure how to call the virtual method outside of methods in
the super class.  As you can see, this example simply forwards the return
from the base class's method.


  • Administrator
  • Hero Member
  • Chief Administrator
  • Posts: 771
  • Karma: +0/-0
  • Time reveals truth.
    • Bob Sellon's Home Page
We want to call the base class's version of function from within our overridden one.