Revisited: Building Cross Platform GUI Apps With PHP-GTK - Registering multiple callback functions (Page 6 of 10 )
One of the great things about PHP-GTK is that you can register multiple callback functions for any signal. This can come in handy when you need to perform multiple tasks when a button is clicked, a window is closed, a tree is expanded, etc.
Let's take a quick look at how to register multiple callback functions for the destroy signal of our window that we created above in window.php:
// Set a callback function for the destroy signal
echo("This is some output before the killwin function is called.\n");
As you can see, i've added another call to our windows connect function, specifying that it should also call the function1 function when it is destroyed. I've placed the call to connect("destroy", "function1") before the call to connect("destroy", "killwin"). This is an important point to remember: the order in which you register the callback functions is the order in which they will be executed.
The output to my console window from running window.php with the new callback handler and function looks like this:
C:\>php -q window.php
This is some output before the killwin function is called.