Brian W Posted March 14, 2011 Share Posted March 14, 2011 Is there a call_user_func_array() alternative other than eval()? With the shear genius of some of the individuals on this forum, I'd expect that if there is an alternative, someone here would know it. Any tips or insight greatly appreciated. Thanks Background (blah blah blah) I'm being kinda picky on efficiency and performance since I will be looking at possible hundreds of executions a request... so I'd like to avoid using the above mentioned functions since they take ~3x and ~10x longer (according to a this comment). Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/ Share on other sites More sharing options...
AbraCadaver Posted March 14, 2011 Share Posted March 14, 2011 It depends on what you're trying to do. call_user_func_array() is slower than calling the function as usual, so that is your alternative: my_function($arg1, $arg2, $arg3); Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187441 Share on other sites More sharing options...
Brian W Posted March 14, 2011 Author Share Posted March 14, 2011 AbraCadaver, I of course realize I could call the function directly and that would be faster. This issue I have is that I am working with mysqli_stmt::bind_param( string $types , mixed &$var1 [, mixed &$... ] ) which accepts basically limitless params. There are solutions to doing this dynamically, but they all utilize the call_user_func_array which like I said is less than desirable. I don't want to waist too much time spinning my wheels on alternatives, but then again I'm not stuck until I get it done or anything so I'm willing to take some time finding the best solution. Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187444 Share on other sites More sharing options...
AbraCadaver Posted March 14, 2011 Share Posted March 14, 2011 I see... In that case I don't really think there is an alternative, but maybe someone else has an idea. Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187452 Share on other sites More sharing options...
Brian W Posted March 14, 2011 Author Share Posted March 14, 2011 Thats what I'm hoping. Some of the Sr. Devs on here are amazing and know of tricks I'd never think of. Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187454 Share on other sites More sharing options...
lastkarrde Posted March 15, 2011 Share Posted March 15, 2011 Use call_user_func_array. Many popular frameworks (Symfony, Zend) do, performance impact is negligible compared to the gains you can get through caching, using an opcode cache etc.. Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187640 Share on other sites More sharing options...
salathe Posted March 15, 2011 Share Posted March 15, 2011 Use call_user_func_array() until you can identify (with real numbers and pretty bar charts) that it is becoming a problem area for your script/application, if that point ever arrives. Quote Link to comment https://forums.phpfreaks.com/topic/230619-call_user_func_array-alternative/#findComment-1187735 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.