__call for existing methods?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there a way to catch EVERY method of a inheritance class?
something like this...

class Father
{
	public function __call ($name, $args)
	{
		$this->doSomethingBefore();
		
		if ( method_exists($this, $name) )
			return $this->$name($args);
		else
			echo 'invalid method';
	}
	
	public function doSomethingBefore ()
	{
		echo 'something before called method';
	}
}

class Son extends Father
{
	public function insert ()
	{
		echo 'inserting';
	}
}

$johnDoe = new Son();

$johnDoe->insert();
/*
-- Expected return:
something before called method
inserting
*/

$johnDoe->foo();
/*
-- Expected return:
something before called method
invalid method
*/

Greetings...

-- 
Maximiliano Churichi
<mchurichi@xxxxxxxxx>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux