News Feed
Sections




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

Jose da Silva's Blog:
Revisiting PHP 5.3 __invoke magic method
November 05, 2010 @ 12:42:04

In a new post to his blog Jose da Silva briefly looks at a feature that was introduced in the PHP 5.3.x series of the language - the __invoke magic method.

PHP version 5.3 introduced a new magic method designed __invoke, this method is called when a script tries to call an object as a function. [...] As php cannot accommodate pseudo-first-class functions, the __invoke method can be used to suppress this language limitation. On other hand you can use this for simpler things as pass a function around.

He includes a simple code example that shows a basic class being called via a variable name - $c('ford') - and the result of its __invoke method being called. He notes that the method, in his opinion, could make for less clean code.

8 comments voice your opinion now!
invoke magic method opinion example


blog comments powered by Disqus

Similar Posts

Lukas Smith's Blog: Stop building gold on top of crap

Reddit.com: Any ideas on what "MVC agnostic" PHP code is?

Michael Babker's Blog: The Death of Joomla! - Negative Attitudes & Closed Minded Leadership

PHPClasses.org: A PHP killer feature - Streams abstraction

Chris Cassell's Blog: Creating Magic Methods in PHP


Community Events





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


podcast framework conference tips introduction release list voicesoftheelephpant bugfix interview series threedevsandamaybe deployment code laravel symfony language api community zendserver

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