News 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

Richard Thomas' Blog: Direction of Zend Framework?

Asvin Balloo's Blog: SEO friendly URL in PHP

Stubbles Blog: Loading classes from the XP-Framework

David Sklar\'s Blog: Parsing Reasonably-sized HTTP Responses

Dallas PHP User Group: PHP5 & LAMP Classes at North Lake College


Community Events





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


series bugfix wordpress interview laravel api introduction list configure threedevsandamaybe language install developer release unittest podcast community library application code

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