note 85779 modified in language.oop5.autoload by danbrown
| From: | danbrown@php.net | Date: | Wed, 17 Sep 2008 15:35:22 +0000 |
| Subject: | note 85779 modified in language.oop5.autoload by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144480@lists.php.net to get a copy of this message | ||
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.
--was--
In a subclass, I was trying to call an overridden parent method with an arbitrary number of
arguments:
<?
call_user_func_array(array('parent', 'someNonStaticMethod'), $args);
?>
It turns out this triggers an E_STRICT level warning. So I changed to this:
<?
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:
<?
function __autoload($cls)
{
if ('parent' != $cls)
{
require("class.$cls.php");
}
}
?>
Tested on Linux with PHP 5.1.6 and 5.2.5.
http://php.net/manual/en/language.oop5.autoload.php