News Feed
Sections




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

Maarten Balliauw's Blog:
Extension methods for PHP
May 18, 2010 @ 09:41:24

In his most recent blog post Maarten Balliauw proposes an idea of something to be included into PHP that .NET developers are used to as commonplace in their language - extension methods.

For the PHP-related audience, this is probably something new. Let's start with the official definition for extension methods: Extension methods enable you to "add" methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. Extension methods are a special kind of static method, but they are called as if they were instance methods on the extended type.

He gives a code example of the concept, showing how you could add this sort of functionality to a PHP class with the help of the __call magic method and some of the Reflection features. The real usefulness, he notes, would be if the idea made it into the core rather than having to do it with the hack he's shown.

0 comments voice your opinion now!
extension method example dotnet static method


blog comments powered by Disqus

Similar Posts

Developer.com: DB2 Universal Database and the PHP Developer? Absolutely!

Pierre-Alain Joye's Blog: ext/filter, API frozen (!) and fixes, 0.11.0 is out

Scott Johnson\'s Blog: Your Simple PHP Code Snippet for Monday

Zend Developer Zone: Mastering Joomla! 1.5

Marcelo Gornstein's Blog: Sniffing in PHP using libpcap: Thank you SWIG!


Community Events





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


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

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