PHP-GTK say “Hello World!”

PHP-GTK say “Hello World!”

PHP-GTK say Hello World!
PHP-GTK say Hello World!

As usual, we start coding dg show kata2 ‘Miracle’ this debate. I press the button that the user writings “Hello World!”, “But it will be writing in-print to the console (it in the windows, command prompt)

if (!class_exists('gtk')) {
if (strtoupper(substr(PHP_OS, 0,3) == 'WIN'))

function shutdown()
print(“Mati deh….”);

function hello()
global $window;
print “Hello World!”;

$window = &new GtkWindow();
$window->connect(‘destroy’, ‘shutdown’);

$button = &new GtkButton(‘Hello World!’);
$button->connect(‘clicked’, ‘hello’);




Let’s surgical contents:
6 line, which made the point that the first load PHP-GTK extension of the OS-appropriate it. I windows, php_gtk.dll, but in linux,
Sure we jump to the first part of the main program.
$ window = & new GtkWindow ();
make the point that defines the new instance, to name a GtkWindow (). She language, make it a new window.

$ window-> connect ( ‘Destroy’, ‘shutdown’);
It is, we manggil method connect (), a window in his Destroy, it’s shutdown function executed. And the shutdown function in its own contents gtk: main_quit () is a loved-shutdown applications PHP-GTK.

$ button = new GtkButton & ( ‘Hello World!’);
$ button-> connect ( ‘clicked’, ‘hello’);
$ window-> add ($ button);
Well, now we try to make buttons. First, in the first definisiin, “but in-connect, I clicked in, then he will call the function hello (to-be Hello World bank in the console),” but add to the window.

$ window-> show_all ();
gtk: main ();
And do not forget to show_all (), though all year I make it in the window.
I gtk: main () function is a program we memberitau I finished, and will continue in the loop, while continuing nunggu interaction from the user, in this loved-loved and click the button-close the window. I was, trying to save petroleum (for example, the file name it hello.php-gtk) and a walking program:
php-q directory / hello.php-gtk
Let say again …. HELLO WORLD!

Sumber :