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
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)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.