Polymorphism in PHP: Virtual function overides parent function but parent function still gets called
<p>I have been programming in C++ but have moved to PHP for a while it seems like polymorphism is different in PHP.  I know that in PHP, all functions that are not private (i.e. public/protected) are in fact also virtual.  Here is my child class definition</p>

<pre><code>class Child extends Parent {
   public function foo() {

   }
}
</code></pre>

<p>then my Parent looks like</p>

<pre><code>class Parent {
   public function foo() {

}
}
</code></pre>

<p>I want my child class to use all of the parent's code apart from the <code>foo()</code> function - I want the child to use its own <code>foo()</code> function.</p>

<p>The issue is that the parent's <code>foo()</code> is still called.  Interestingly, my IDE (NetBeans) says that it is getting overridden correctly.</p>

<p>I am using <code>$this-&gt;foo()</code> in the parent and child.. this should be ok yes?  It just says 'execute the function foo for the current object'.. maybe I'm going wrong here?</p>

<p>Thank you.</p>
