rtconner Posted March 20, 2007 Share Posted March 20, 2007 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 More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 <?php function foo($arg1, $arg2, $arg3) { bar($arg1, $arg2, $arg3); } ?> I think that might be what you want? Link to comment https://forums.phpfreaks.com/topic/43577-pass-args-from-one-method-to-the-next/#findComment-211672 Share on other sites More sharing options...
rtconner Posted March 21, 2007 Author Share Posted March 21, 2007 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 https://forums.phpfreaks.com/topic/43577-pass-args-from-one-method-to-the-next/#findComment-212353 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 http://us3.php.net/func_get_arg Maybe that is what you are looking for? Link to comment https://forums.phpfreaks.com/topic/43577-pass-args-from-one-method-to-the-next/#findComment-212365 Share on other sites More sharing options...
rtconner Posted March 22, 2007 Author Share Posted March 22, 2007 Actually, you are close... I think I got it... call_user_func('bar', func_get_args()); might work. I have yet to test this, but in concept it should do the job. Link to comment https://forums.phpfreaks.com/topic/43577-pass-args-from-one-method-to-the-next/#findComment-213024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.