effigy Posted June 12, 2006 Share Posted June 12, 2006 Hey folks,I've returned for now and I'm trying to get back to speed. Is it possible to attach a function (method) to an existing method of a class? More specifically, every time I call [!--fonto:Courier New--][span style=\"font-family:Courier New\"][!--/fonto--]mysqli->query[!--fontc--][/span][!--/fontc--], I'd like it to do its thing, [i]and[/i] more.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/11783-attaching-a-trigger-to-an-existing-class-method/ Share on other sites More sharing options...
Barand Posted June 12, 2006 Share Posted June 12, 2006 You could extend the existing class[code]class theClass { function do_something() { echo 'foo'; }}class my_class extends theClass { function do_something() { parent::do_something(); $this->do_something_else(); } function do_something_else() { echo 'bar'; }}$x = new my_class;$x->do_something(); // ---> foobar[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11783-attaching-a-trigger-to-an-existing-class-method/#findComment-44703 Share on other sites More sharing options...
effigy Posted June 12, 2006 Author Share Posted June 12, 2006 Thanks Barand. I found this helpful as well:[a href=\"http://www.zend.com/php5/articles/php5-mysqli2.php#Heading5\" target=\"_blank\"]http://www.zend.com/php5/articles/php5-mysqli2.php#Heading5[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11783-attaching-a-trigger-to-an-existing-class-method/#findComment-44723 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.