News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Community Crosstalk:
Matthew O'Phinney & Scott Johnson on Dynamic Function/Method Calls
June 26, 2006 @ 06:14:51

In two related posts from Scott Johnson and Matthew Weir O'Phinney, there's a question about metaprogramming in PHP, specifically between the use of call_user_func, call_user_func_array, and variable function calls (as asked by Scott).

One of the characteristics of meta programming is lots and lots of dynamicism everywhere. So here's my php question: Is there a real difference between call_user_func versus call_user_func_array and the variable function syntax i.e. $function_name() ? As best as a quick experiment shows they seem to function the same although I did a quick hack / quick doc check as opposed to really drilling into it. Any efficiency benefits in doing it one way or another?

Matthew replies on his blog by running some benchmarks (and wondering why Scott didn't run his own).

Back to benchmarking. Scott asks, "Is there a real difference between call_user_func versus call_user_func_array and the variable function syntax i.e. $function_name()?"

The short answer: absolutely. The long answer? Read on.

He details what the differences are in the functionality (how they're used and all) as well as examples of their usage. He whips up a test class and function to go through different benchmarks, testing response times with the microtime functionality of PHP. He results aren't too surprising, but you'll have to check out his post to get the full details.

0 comments voice your opinion now!
dynamic function method benchmark class microtime call_user_func dynamic function method benchmark class microtime call_user_func


blog comments powered by Disqus

Similar Posts

WaxJelly Blog: How to write a custom Smarty function in PHP

Derick Rethans: Mongo is dead, long live MongoClient

L2Admin.com: Battle of the server side scripting languages - Perl, Python & PHP

DevShed: Effects of Wrapping Code in Class Constructs

AlternateInterior.com: Multi-Threading Strategies in PHP


Community Events











Don't see your event here?
Let us know!


unittest hhvm package language dependency symfony2 framework application composer hack code component release facebook opinion security podcast series install introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework