PHP Conference Japan 2021 Online

Voting

Please answer this simple SPAM challenge: two plus one?
(Example: nine)

The Note You're Voting On

jbarker at erepublic dot com
12 years ago
In a subclass, I was trying to call an overridden parent method with an arbitrary number of arguments:

<?php
call_user_func_array
(array('parent', 'someNonStaticMethod'), $args);
?>

It turns out this triggers an E_STRICT level warning. So I changed to this:

<?php
call_user_func_array
(array($this, 'parent::someNonStaticMethod'), $args);
?>

This doesn't trigger any warnings, but it has the undesirable (if not downright buggy) effect of calling my __autoload() function with the argument 'parent'. I had to modify __autoload() to handle this special situation:

<?php
function __autoload($cls)
{
    if (
'parent' != $cls)
    {
        require(
"class.$cls.php");
    }
}
?>

Tested on Linux with PHP 5.1.6 and 5.2.5.

<< Back to user notes page

To Top