Study Guide: PHP Programming->PHP-GTK

Back to PHP

As you should have already learned in previous sections of this study guide. PHP is more than just a web server language. It can be used to create GUI applications, shell like scripts, and even daemons, among other things. This chapter focuses on using PHP to create GUI applications using PHP-GTK.

What is PHP-GTK

PHP-GTK is a GTK+ and GNOME language binding for PHP. That's just a fancy way of saying that PHP-GTK makes it so that GNOME and GTK+ programs can be written using PHP.

You have to have PHP-CLI and GTK installed on your box.

For questions, search or browse this PHP GTK Forum hosted by Nabble.

Example PHP-GTK Program

Below is a very simple PHP-GTK program. It just creates a window that doesn't do anything. In fact, as you'll find out if you run it, this window won't even close if you try to close it using the normal means.

  $window = new GtkWindow;

This is a little more complex than your usual Hello World program. But we'll go through it step by step.

The first line:

       $window = new GtkWindow;

creates a new GTK+ window. One thing to note about GTK+ and GNOME programming is that when you create a window it does not automatically get displayed. (That's what the next line does.)

The next line:


displays the newly created window.

The last line:


is where all the magic happens with GTK+. For now, just take my word for it that you need to call this to make you GTK+ program run.

External Links

Authors Note: This chapter is still un-done. More will be coming later.

  This article uses material from the Wikipedia page available here. It is released under the Creative Commons Attribution-Share-Alike License 3.0.



Connect with defaultLogic
What We've Done
Led Digital Marketing Efforts of Top 500 e-Retailers.
Worked with Top Brands at Leading Agencies.
Successfully Managed Over $50 million in Digital Ad Spend.
Developed Strategies and Processes that Enabled Brands to Grow During an Economic Downturn.
Taught Advanced Internet Marketing Strategies at the graduate level.

Manage research, learning and skills at Create an account using LinkedIn to manage and organize your omni-channel knowledge. is like a shopping cart for information -- helping you to save, discuss and share.

  Contact Us