<?phperror_reporting(E_ALL);// Superclass for determining action - in realite this holds a whole bunch of other shared functions as well.abstract class superclass { var $validActions = array(); function determineAction($action='') { echo 'Determining Action...<br />'; if(!in_array($action,$this->validActions)) { $this->invalidAction(); } elseif(method_exists($this,$action)) { $this->$action(); } elseif(method_exists($this,'defaultAction')) { $this->defaultAction(); } else { die('Geen default action ingesteld voor deze klasse!'); } }}// Extends super with actions and other functions. Only actions should be allowed to be called through determineActionclass subclass extends superclass { var $validActions = array('showPage','destroyDatabase'); function showPage() { echo 'Hier een actie van subclass genaamd showPage...<br />'; } function destroyDatabase() { echo 'Database wissen mislukt, probeer het via Enterprise Manager!<br />'; } function defaultAction() { echo 'De defaultAction van subclass...<br />'; }}class wrongsubclass extends superclass { function showPage() { echo 'Foute subklasse laat van zich horen...<br />'; }}$test = new subclass();$test->determineAction('Foo'); // Action does not exist, should show subclass::defaultAction$test->determineAction('showPage'); // Does exist, should show subclass::showPage$test2 = new foutesubclass();$test2->determineAction('Foo'); // Doesn't exist, missing defaultAction?>