News Feed
Sections




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

Gonzalo Ayuso's Blog:
Runtime Classes. A experiment with PHP and Object Oriented Programming
August 08, 2011 @ 09:17:05

Gonzalo Ayuso has put together an experiment related to the current OOP structure of PHP - a test working with runtime classes, a structure generated entirely when the script is executed and not predefined in the file.

Last week I was thinking about creation of a new type of classes. PHP classes but created dynamically at run time. When this idea was running through my head I read the following article and I wanted to write something similar. Warning: Probably that it is something totally useless, but I wanted to create a working prototype (and it was fun to do it).

His class is pretty basic - a "Human" object that echoes a "hello world" sort of message via a "hello()" method. He creates the classes inside of different test methods to ensure that his assertions are true. The tests check basic output of the "hello()" method, calling undefined methods, testing inheritance and a test creating and evaluating a dynamic function.

For something more complex, he creates a dynamic class that solves the FizzBuzz kat, a popular programming puzzle. You can find the full code for this and his other examples on github.

0 comments voice your opinion now!
runtime class experiment objectoriented oop fizzbuzz


blog comments powered by Disqus

Similar Posts

Stefan Mischook's Blog: PHP Classes and Objects video tutorial

Zend Developer Zone: NestedSetDbTable class

Stefan Mischook's Blog: Object Oriented PHP Tutorial Updated - Steps 18 - 22

Lorna Mitchell's Blog: PHP REST Server (Part 1 of 3)

Chris Justus' Blog: 4 Reasons Java Will Outlive PHP (My interview with IEEE...)


Community Events

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


framework api conference extension laravel5 podcast opinion library laravel release unittest php7 interview language version series introduction example voicesoftheelephpant community

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