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. Quote Link to comment 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? Quote Link to comment 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) Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.