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. 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] 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] 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
Archived
This topic is now archived and is closed to further replies.