RE: [PHP] Calling parent function with call_user_func_array



Thanks for taking the time to reply.

I'm working on a Wordpress theme and extending one of their existing
classes (the Walker class if you're familiar with WP). Since WP still
supports PHP4, my theme needs to as well.

-----Original Message-----
From: Jochem Maas [mailto:jochem@xxxxxxxxxxxxx]
Sent: Thursday, November 29, 2007 5:06 PM
To: Tommy Baggett
Cc: php-general@xxxxxxxxxxxxx
Subject: Re: [PHP] Calling parent function with call_user_func_array


Tommy Baggett wrote:
I'm a self-confessed PHP newb (first step towards a cure, right?), so

if these are your first steps why use php4? php5 has been out for going
on 3 years.

apologies in advance for what may be a basic question. I spent an
hour searching for an answer to this and couldn't find one.

I found one post that said there was a problem with this in 5.0.3, but

it didn't indicate whether the fix was also applied to the PHP4
branch.

I'm using PHP v4.4.7. I have class B which extends class A. I'm
overriding a function that is normally called with a variable number
of parameters via call_user_func_array. How do I call the class A
implementation of the function using call_user_func_array from the
class B implementation?

class A {
function doSomething($elements, $level) {
...
}
}

Class B extends A {
function doSomething($elements, $level) {
...
call_user_func_array(/*class A implementation of doSomething*/,
args);

does this work:?

call_user_func_array(array(parent,'doSomething'),$args);

it's an educated guess, no garantees.

}
}

Thanks in advance for any help!

.



Relevant Pages

  • Re: Current class name for use with ::
    ... refers to 'the current class' in the way you want it to. ... public function printConst() ... class B extends A { ... PHP does have an advantage over other OO languages such as Java and C++ in that it is a strictly interpreted language - it's not compiled. ...
    (comp.lang.php)
  • Re: Extending the mysqli class
    ... Under PHP 4: ... print "Constructor called\n"; ... // it extends A. ... There is no clue within ...
    (comp.lang.php)
  • I want to pass Sub Window the value with PHP and JavaScript.
    ... extends without trouble ... Data cannot be received though new Sabwindow opens when assuming "<a ... it is LINUX and PHP is PHP 4.3.9. ... The experimented client environment is peel WindowsXPSP2, ...
    (php.general)
  • "extends" versus "aggregates" in UML CRC
    ... brick walls so I'd like to hear what the general consensus is on this ... or an aggregation, in the context of a CRC diagram. ... I've been using extends up until now, but I have a feeling that aggregates ... The problem is that PHP has it's own ...
    (alt.php)