<?php

	class car {
		
		//method to get class method
		public function get_method($method_name) {
			$class = new ReflectionClass(get_class($this));
			$method = $class->getMethod($method_name);
			$method->setAccessible(true);
			return $method;
		}
		
		public function exec_method($method_name, $arg_args=array()) {
			
			//execute the pre() function before the specified method
			$this->pre();
			
			//execute the specified method
			$this->get_method($method_name)->invokeArgs($this, $arg_args);
		}
		
		public function pre() {
			echo 'pre';
			echo '<br />';
		}
	}
	
	class toyota extends car {
		private function drive() {
			echo 'drive';
			echo '<br />';
		}
		
		private function brake() {
			echo 'brake';
			echo '<br />';
		}
	}
	
	$toyota = new toyota();
	$toyota->exec_method('drive');
	$toyota->exec_method('brake');
?>