PHP/GTK_PHP tutorial

Source: Internet
Author: User
PHPGTK. In the past, PHP was considered to be only used to write CGI programs on the server. If PHP can develop GUI (Graphical User Interface) programs in Windows, do you believe this? Recently, PHP's development team succeeded. Previously, PHP was considered to be only used to write CGI programs on the server. If PHP can develop GUI (Graphical User Interface) programs in Windows, do you believe it? Recently, the PHP development team has successfully developed a PHP program bound with GTK +, so you can develop GUI programs in Windows. 1. create a PHP/GTK runtime environment: in fact, the GUI program is no different from the common PHPCGI program, but the PHP/GTK program is used by the GTK class to generate the GUI, they are also open source code, which relies on PHP to parse and establish a window. If you have already set up the PHP debugging environment, it is relatively simple to install the PHP/GTK environment: 1. download php_gtk.dll (this dll file is used to parse the GTK code in the PHP source program ), decompress the downloaded file to the extension directory of PHP. 2. download the dll files of other PHP/GTK files (6 in total) and decompress them to the system32 directory of Windows; 3. open php. ini: add the "extension = php_gtk.dll" statement at the bottom of "Windows Extensions" in the extended settings section. we recommend that you back up php first. ini to avoid modification failure and invalidate the established PHP runtime environment. now the PHP/GTK runtime environment has been established. Of course, you can also add "dl (php_gtk.dll)" to the first line of the source code of each PHP/GTK program to dynamically load GTK. If you have not yet created a PHP runtime environment, the installation should be simpler: 1. download the entire PHP/GTK bundle support package and decompress them to the PHP4 directory of drive C; 2. copy the dll file under the winnt directory to the system32 directory of Windows, and set php. copy the INI file to the Windows directory. after you have set up PHP/GTK to run, you can run a PHP/GTK program in command line mode: Enter "c: php4php-q gtkprogrampath ", where" c: php4php "is changed to PHP. EXE path. "gtkprogrampath" is the path of the PHP/GTK program. For example, "c: php4php-q c: php4sampleshello. php" will run the example "hello world" program included in the PHP/GTK runtime package. 2. Compile the PHP/GTK program: If you make a PHP/GTK application, it is too complicated to build a PHP runtime environment on the other computer and use the PHP command line mode for parsing. So how can we compile a PHP/GTK program? After some searches, I found the PHPCompiler software. PHPCompiler developed by www.mongocode.com ( http://www.deskcode.com/phpcompiler ), PHP can be compiled into an EXE executable file with built-in PHP support. if you want to compile a PHP/GTK program, you must create a runtime environment for PHP/GTK (refer to the previous steps ). To compile a PHP/GTK program, follow these steps: 1. open PHPCompiler () and select the source code of the PHP program to be compiled in "Script, select the path of the compiled EXE file at "Destination". 2. click "Compile, A dialog box will pop up asking about the compilation mode used (if it is a PHP/GTK program, select no, if it is a pure PHPCGI program, select yes ); 3. a dialog box will pop up asking if to copy php4ts. to the Directory of the compiled EXE file, select yes. After the above steps, a PHP/GTK program is successfully compiled, but there are several notes for compiling the PHP/GTK program: 1. if you need to execute the compiled executable files, the PC must have several dll files required for the GTK Runtime Environment (the ones downloaded earlier). If you need to build an application, several dll files can be copied to the system32 directory during installation (however, the subroutine is not "green software" ^_^ ). 2. PHPCompiler supports PHP very well, but some people have tried to use some functions that need to be extended, such as "gzopen". it should be well prepared before compilation, it cannot be used after compilation. In fact, after compilation, the executable file is equivalent to only the default PHP support (even GTK support is not available). Therefore, if you have applied any function that requires extension support in the program, all dll files supporting functions must be dynamically loaded, such as "dl (php_gtk.dll)", so that no errors will occur after compilation. 3. when running a compiled executable file, a DOS window is displayed and closed automatically, because each GUI window is "drawn" by GTK, so there must be that window. 4. in the past, PHP may not be the real OOP language. However, when PHP/GTK is reached, any window is "drawn" by the GTK object ", without excellent OOP skills, it is difficult to write GUI programs. III. PHP/GTK resources: 1, http://gtk.php.net : PHP/GTK official website. although it is an official website, it is very simple. a FAQ and email list are provided, and almost no useful things can be found. 2, http://www.phpgtk.com : A PHP/GTK website with the latest version information. 3, http://developer.gnome.org/doc/API/gtk/gtkobjects.html : PHP/GTK functions and classes/manual website, which contains a wealth of PHP/GTK information. 4, http://www.phpuk.org/gtk/ : Non-official GTK manual website, easy to understand. If you think E is ugly, you can also download the latest PHP/GTK runtime environment and support package from zphp.com.

Do you believe the graphic user interface program? Recently, PHP development team succeeded...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.