Diao Chan published in 2002-2-19 15:25 PHP programming ← Return layout
PHP was previously thought to be used only to write server-side CGI programs, if PHP can develop a GUI (graphical user interface) program under Windows, do you believe it? Recently, the PHP development team successfully developed PHP bundled with GTK +, so you can develop GUI programs under Windows.
First, the establishment of PHP/GTK operating environment:
In fact, GUI programs and ordinary phpcgi program is no different, but PHP/GTK program by the GTK class to generate GUI interface, they are also open source code, rely on PHP to resolve the establishment of Windows. If you have set up the debugging environment of PHP, then the installation of PHP/GTK environment is relatively simple:
1, download php_gtk.dll (this DLL file to parse the PHP source code inside the GTK), download it to the extension of PHP (extension) directory;
2, download other PHP/GTK DLL files (altogether 6), unzip them to the Windows System32 directory;
3, open php.ini, in the Extended Settings section "Windows Extensions" Add the "Extension=php_gtk.dll" statement, we recommend that the first backup php.ini, to avoid the failure to modify the establishment of a good PHP operating environment void;
Now it's time to set up the PHP/GTK's operating environment. Of course, you can also add "DL (' Php_gtk.dll ')" to dynamically load GTK support instead of the second step in the first line of each PHP/GTK program source code.
If you haven't built a PHP run environment yet, it's easier to install:
1, download the entire PHP/GTK bundle support package, and then unzip them to the C-disk PHP4 directory below;
2, copy the DLL file in the Winnt directory to the Windows system32 directory, and copy the php.ini file to the Windows directory;
After the PHP/GTK is established, you can run a PHP/GTK program using command-line php: Enter "C:\php4\php-q Gtkprogrampath" in the runtime, where "c:\php4\php" is changed to PHP.EXE path, " Gtkprogrampath "is the path to the PHP/GTK program. For example, "C:\php4\php-q c:\php4\samples\hello.php" will run the example "Hello World" program that accompanies the PHP/GTK run package.
Second, compile the PHP/GTK program:
If you make a PHP/GTK application, you need the other computer to build PHP's operating environment and use the PHP command-line mode to parse before it can be executed, which is too complicated. So how can you compile a PHP/GTK program? After a search, the author found phpcompiler this software.
Phpcompiler by Www.deskcode.com Development (Http://www.deskcode.com/phpcompiler), PHP can be compiled into EXE executable file, built-in PHP support, if you want to compile a php/ GTK program, you must establish a PHP/GTK running environment (refer to the previous steps). The steps to compile a PHP/GTK program are as follows:
1, open Phpcompiler (as pictured), in the "Script to" select the PHP program to compile the source code, in the "destination" to choose the compiler after the successful EXE file path;
2, click the "Compile" button, will pop up a dialog box to ask the use of the compilation mode (if the PHP/GTK program on the choice of No, is a simple phpcgi program to choose Yes);
3, and then will pop up a dialog box asking whether to copy the Php4ts.dll file to the compiled EXE file directory, select Yes.
After the steps above, a PHP/GTK program compiles successfully, but there are several points to note for compiling the PHP/GTK program:
1, after compiling the executable file if necessary, the PC must have a GTK running environment required several DLL files (that is, the previous download of the several), if you need to make an application, You can copy several DLL files to the System32 directory at installation time (but this is not a "green software" ^_^).
2, Phpcompiler itself for the support of PHP is very good, but some people have tried to extend the support of the function, such as "Gzopen" and so on, before compiling a good, after the compilation is not used. In fact, after compiling the executable file, the equivalent of only the default PHP support (even GTK support is not available), so if you applied in the program any need to extend the support of the function, you must dynamically load the supporting function of the DLL file, such as "DL (' Php_gtk.dll ')", This will not make a mistake when the compilation is complete.
3, run a compiled executable file, will first pop up a DOS window, and then automatically shut down, because each GUI window is through the GTK to "draw" out, so must have that window.
4, perhaps the previous PHP can not be said to be the real OOP (object-oriented program) language, but to the PHP/GTK, any window by the GTK object to "draw", if there is no perfect OOP skills, it is difficult to write GUI programs.
Third, PHP/GTK resources:
1, the official website of Http://gtk.php.net:PHP/GTK, although it is the official website, but it is very simple, out of a FAQ and mailing list, can hardly find anything useful,
2, http://www.phpgtk.com: A Better Interface PHP/GTK website, has the latest version information.
3, Http://developer.gnome.org/doc/API/gtk/gtkobjects.html:PHP/GTK function and class of the encyclopedia/manual site, which has very rich php/gtk information.
4, http://www.phpuk.org/gtk/: Unofficial version of the GTK manual website, easy to understand.
If you think that E is more ugly, you can also come to zphp.com download the latest PHP/GTK operating environment and support packages.
Signature:
Laugh and say the words from the beginning
Proud of the drunken sword continued to the front
Leopards Fingers
The lake Sea wanders the wild crane leisure
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.