News Feed
Sections




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

DevShed:
Simulating Events with PHP 5
February 21, 2006 @ 06:46:23

On DevShed today, there's this new tutorial aimed at more advanced PHP developers concerning how to simulate events in PHP5.

PHP has the drawback of not supporting events. Fortunately, a basic structure can be built to support events in PHP 5. This article tackles that problem with some proof of concept code.

It seemed reasonable to me that some sort of basic structure could be established to support events in PHP 5, so I set out to whip something up as quickly as possible as a proof of concept. The contents of this article are the work of roughly one programming hour and surely stand to be improved upon, but the basic idea is this: instantiate an object and attach event handlers; the handlers will be executed when the events they are associated with are raised.

They look first at how to create a simple object to store the information in and a "collection" class to manage those objects. They move on to the creation of the event handler class and a "collection" class for handling those as well. Finally, they get to the combination of the above items - a class that does an eval on the inputted string and creates an associative array.

0 comments voice your opinion now!
simulate events php5 collection class trigger handler simulate events php5 collection class trigger handler


blog comments powered by Disqus

Similar Posts

David Parra's Blog: Compiling PHP under OpenSolaris

DevShed: Enforcing Object Types in PHP - Using the PHP5 instanceof Operator

The Shadow Fox Network: Creating A Scaffold-like Class in PHP or An Automatic CMS For a Table

Technobabbler.com: making a radar loop with PHP

Gentoo Blog: PHP's Simplicity Can Confuse Folks Looking For Complexity


Community Events





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


opinion list threedevsandamaybe unittest testing developer interview release community refactor symfony2 language series code install laravel introduction configure framework podcast

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