The Observer Pattern in PHP 5

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Last week I continued my series of design patterns examples using PHP
5.  Here now is my 14th example, the Observer pattern.

In the Observer Pattern, a Subject object notifies an Observer object
if it's the Subject object's state changes.

Pretty simple and fairly useful.

An application for this pattern might be having a Subject object with
the state of a web page, and an Observer object which can produce RSS
feeds.  If the Subject page changes it notifies the Observer object,
which produces an RSS feed for the changed page.

Site Timeline