Do You PHP はてブロ

Do You PHPはてなからはてブロに移動しました

PHPでプロトタイプベースプログラミング

PHPでプロトタイプベースプログラミングを実現してみた方がいるようです。ちょっと無理矢理っぽいなぁ、という感じもしなくもないですが、雰囲気はかなり出てますね :-)
基底クラスに関数名と対応する実装を格納し、__get/__set/__callメソッドをうまく使ってます。


For those who have been doing a lot of Javascript programming, you know what prototype-based programming is all about. The basic idea is that functions can be added to classes dynamically. In Javascript functions can be added to a static class (using prototype) and it will be added to all instances of the class, or they can be added to a specific instance and only be added to that instance.