# Advanced OO Topic

- Thread: https://externals.io/message/9887
- Original archive: https://news-web.php.net/php.internals/9887
- Started by Robert Peake on 2004-05-17T02:52:19+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9887 — Robert Peake — 2004-05-17T02:52:19+00:00

URL: https://externals.io/message/9887#9887

Hi,

I notice a strange behavior in PHP4 and wonder if anyone can explain it.

Essentially, when I extend a class from a built-in module, I can add and
access variables but can not access new functions I create within the
extended class. 

This has only happened attempting to extend classes from ming, but I suspect
it may be a universal problem (?).

That is:

<?PHP
class foo {

}

class bar extends foo {
  function bar() {
    print "bar";
  }
}

$bar = new bar();
$bar->bar(); //PRINTS "bar"
?>

Works as expected, however, in:

<?PHP

class foo extends SWFSprite {
  
  var $x = 10;

  function bar() {
    print "bar";
  }

}

?>

running:

<?PHP

$foo = new foo();
print $foo->x; //WORKS; PRINTS "10"
$foo->bar(); //RETURNS "Undefined Function" FATAL ERROR

?>

Can anyone explain this behavior? Will it be fixed in PHP5? Is it related to
the Zend engine? Any workarounds?

Many thanks in advance.

Best,
Robert

-- 
Robert Peake         |  Peake Professional Consulting
Robert@PeakePro.com  |  http://www.peakepro.com/
