Tutoriale PHP
  Comunitatea PHP Romania
?>

 
Tutoriale PHP
Index » Noutati

Maarten Balliauw's Blog: Extension methods for PHP


Postat:Marti 18 Mai 2010 9:41
Accesari:1182
Comentarii:0
Favorite:0
Sursa: http://www.phpdeveloper.org

Del.icio.us
Digg
Technorati
Categorii: Noutati

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.

Comentarii


    Ultimele discutii in forum RSS Forum

    Parteneri

    Ultimele articole Ultimele articole

    Membri recenti

    Top membri

    Newsletter


    Email:
     inscriere
     renuntare
     
     Arhiva newsletter
    Copyright © 2001-2017 PHP Romania Gazduire Claus Web | Inregistrare Domenii
    Powered by Simplis