You are here: Re: [PHP] Using parent with call_user_func_array « PHP « IT news, forums, messages
Re: [PHP] Using parent with call_user_func_array

Posted by Chris on 09/03/05 23:11

You know, ... after I posted this, I found another bug (not sure how I
missed it before). This one may actually be the cause of my problem:

http://bugs.php.net/bug.php?id=32290

I don't relish the idea of an upgrade to work around this problem
though. So any thoughts or idea would still be appreciated.

Chris wrote:

> Should these two pieces of code function identically?
>
> $aArgs = array('testarg1','testarg2');
> call_user_func_array(array('parent','AddNewElement',$aArgs)
>
> and
>
> parent::AddNewElement('testarg1','testarg2');
>
> I'm havign trouble debugging this, but my app seems to be going into
> an infinite loop when parent::AddNewElement is called with
> call_user_func_array.
>
> I've found a fairly old bug related to self / parent and
> call_user_func[_array] , but this is nto the same thing. Though the
> discussions of this bug do lead me to believe that
> call_user_func_array should behave as I am expecting it to.
>
> Am I missing something? Is this a bug? Is there a workaround?
>
> More details about my problem follow
>
> Apache2, PHP 5.0.3
>
> I've got a method defined in a class called AddNewElement().
>
> In a sub-class, I'm redefining overloading AddNewElement, and the only
> thing I want to do is add an argument to the argument list, and then
> pass it on to the parent::AddNewElement()
>
> I can't do these statically, as the number of arguments is flexible
> (though it's guaranteed to have at least one argument..
>
> <?php
> ...
> protected function AddNewElement($sClass)
> {
> $aArgs = func_get_args();
> array_splice($aArgs,1,0,(array)$this->NextID());
> return
> call_user_func_array(array('parent','AddNewElement'),$aArgs);
> }
> ...
> ?>
>
> Thanks,
> Chris
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация