You are here: Re: Howto re-pass arguments? « All PHP « IT news, forums, messages
Re: Howto re-pass arguments?

Posted by J.O. Aho on 10/21/07 07:46

zapzap wrote:
> J.O. Aho wrote:
>> zapzap wrote:
>>> Hello :-)
>>> Is it possible to pass all arguments to another function?
>>> function A()
>>> {
>>> B(func_get_args());
>>> }
>>>
>>> function B()
>>> {
>>> var_dump(func_get_args());
>>> }
>>> I dont know how many arguments will come for A, and i want
>>> A to handle them transparent and pass all to B.
>>> Now i'm doing this with func_get_args but I get
>>> an array ob B's input. original arguments would be
>>> better. Is this possible in any way?
>> function b($array) {
>> if(is_array($array)) {
>> foreach($array AS $var) {
>> var_dump($var);
>> }
>> } else {
>> var_dump($array);
>> }
>> }
>
> No no no ;-) My fault, see this:
>
> //
> function A()
> {
> B(); // THIS NEEDS TO BE CHANGED PROBLY :>
> }
>
> //
> function B()
> {
> var_dump(func_get_args());
> }
>
>
> So, I will NEVER call B directly, i'll always call A
> an A will call B for me.

If you want the arguments that are used when you call function A(), you need
to use func_get_args() in function A(), so you would need to use
b(func_get_args()). As you see from b(), it won't present your variables
inside a array.

--

//Aho

 

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

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