<?php
class Row {
	private $observers = array();
	
	function insert($data) {
		foreach ($this->observers as $observer) {
			call_user_func($observer, $data);
		}
	}
	
	function addObserver($observer) {
		$this->observers[] = $observer;
	}
}

class Counter {
	private $counter = 0;
	
	function increment($data) {
		$this->counter++;
		echo "$this->counter\n";
	}
}

$counter = new Counter;
$row = new Row;
$row->addObserver(array($counter, 'increment'));
$row->insert(5); // automaticky zavolá $counter->increment(5)