Jump to content

Pass args from one method to the next


rtconner

Recommended Posts

In python (I forget the exact syntax, its been a while)

 

You can write -

...

function foo(arg,*args, **kwargs) :

    bar (arg, *args, **kwargs);

...

And all of the variable pass to foo() will then be passed on to bar().

Is there a php equivalent? I've looked around and cannot find anything. I'm thinking something with func_get_args might work, but I can't pinpoint it.

 

Thank.

Link to comment
https://forums.phpfreaks.com/topic/43577-pass-args-from-one-method-to-the-next/
Share on other sites

LoL. Not really.

 

In python I could call

 

foo('abc', 5, false, 6, name='joe', type='person', array(1,2,3));

 

And every single one of those parameters would be passed into bar. Its good for passing parameters to your parent classes constructor and then doing some of your own logic in the constructor also. You don't have to have any idea what the parameters are, you just pass them along (or you can use some of them)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.