Saturday, November 28, 2015 
download | documentation | applications | faq | changelog | resources 

search for in the  

Frequently Asked Questions

What is PHP-GTK?

PHP-GTK is a PHP extension that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client side cross-platform GUI applications.

Why is it not working with the browser/web server?

PHP-GTK is not meant to be used in the Web environment. It is intended for creation of standalone applications (run via command-line, user's desktop, etc.).

How do I install PHP-GTK on Win32?

Download the latest binaries from The zip file contains all binaries needed to run core PHP-GTK, as well as extra features such as Glade/XML and Scintilla. Extract the files to a temporary directory and then copy them into the following locations:

For Windows 98/NT/2000/XP:

In your PHP directory (e.g., c:\php4):

  • php.exe
  • php_win.exe
  • php-cgi.exe
  • php.ini
  • php.ini-gtk
  • all .dll files

In a test directory (e.g., c:\php4\test):

  • all .php files
  • testgtkrc
  • testgtkrc2
  • window.xpm

NOTE: You can install the php.ini into your Windows directory (i.e., c:\winnt or c:\windows) as indicated by the zip file, but it is often not a good option, depending on the installation. It is also no longer required; the php.exe (CLI version as of PHP 4.3.0) will search the working directory, e.g., c:\php4, as well as the Windows directory. Or you can specify your php.ini location in your command line statement with '-c' option, as given in the php_win example below.

For Windows 95:

PHP-GTK has not been tested on Windows 95 ... sorry.

Testing the installation

When the PHP-GTK files are installed, you can verify your setup using a DOS command line. A typical example would be: c:\php4\php c:\php4\test\hello.php

To avoid the DOS box, you can use the php_win executable, provided in the install file:

c:\php4\php_win c:\php4\test\hello.php


start c:\php4\php_win c:\php4\test\hello.php


c:\php4\php_win -c \php4\php.ini -f c:\php4\test\hello.php

If you have installed your php.ini file in your Windows directory, the -c option can be dropped. For more information on command line options, see 'Using PHP from the command line' on the main PHP site.


If you can't produce the hello window, try the following:

  • Verify the hello.php location, i.e., [drive:]\php4\test
  • Open hello.php in Notepad, and make sure there is no obvious corruption in the code.
  • Modify your php.ini file, to log any errors, as detailed below.
  • Review the postings at the PHP-GTK discussion list archive for possible solutions.
  • If you still have a problem, subscribe to the PHP-GTK general discussion list and post your question there.


  • To debug your scripts, modify the php.ini file as follows:
    • Find the line for 'log_errors'. Set it to 'On'.
    • Find the line for 'error_log'. Remove the beginning semicolon (uncomment) and replace 'filename' with an actual file location
      Example: error_log=c:\php4\error_log.txt.
    • If the error file does not exist, php will create it on the next run. Open the file and review.
  • If you are planning to launch on an association, decide which extension you want to use for your scripts. Be aware that other applications register .php, so something like .php-gtk might be a better option.
  • You can set your scripts to use Win32 themes, courtesy of Christian Weiske. Check out the info page at:
  • Install the php-gtk launcher. It handles many of the Windows directory issues and provides a series of PHP-GTK icons. Also from Christian.
  • Consider using Glade/XML for setting up your screens and reducing maintenance time.
    Start with the info page at:
How do I use the buttons in GtkFileSelection?
// Create the dialog window:
    $fs = &new GtkFileSelection("Save file");

// Get a handle to the Ok button:
    $ok_button = $fs->ok_button;

// Connect a function:
    $ok_button->connect("clicked", "enddialog");

// Connect the destroy action on the dialog window:
    $ok_button->connect_object("clicked", "destroy", $fs);

It is not currently possible to do it this way:

// Create the dialog window
    $fs = &new GtkFileSelection("Save file");

// Connect a function
    $fs->ok_button->connect("clicked", "enddialog");

// Connect the destroy action on the dialog window
    $fs->ok_button->connect_object("clicked", "destroy", $fs); 
How do I know which GTK Classes are supported?

The following code will show the defined classes. All the PHP-GTK classes will be listed along with one or two others.

$array = get_declared_classes();
while(list(,$classname) = each($array)) {
    echo $classname."\n";

See the Class/Object functionsin the PHP Manual for other useful functions.

Can I use Themes under Win32?

No, The Win32 GTK port does not currently support this.

Where do I go from here?

Check out the Resources page.


PHP  Copyright © 2001-2015 The PHP Group
 All rights reserved.
Last updated: Wed Apr 8 08:10:12 2015 CEST