Home  >  Article  >  Backend Development  >  Practical PHP/GTK_PHP tutorial

Practical PHP/GTK_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:29:15819browse

In the past, PHP was considered to be only used to write server-side CGI programs. If PHP could develop GUI (graphical user interface) programs under Windows, would you believe it? Recently, the PHP development team successfully developed PHP bundled with GTK+, so that GUI programs under Windows can be developed. 1. Establish PHP/GTK operating environment: In fact, there is no difference between GUI programs and ordinary PHPCGI programs. It is just that PHP/GTK programs generate GUI interfaces from GTK classes. They are also open source codes and rely on PHP to parse and create windows. . If you have already established a 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), and extract it to PHP after downloading. In the extension directory; 2. Download other PHP/GTK dll files (6 in total) and unzip them into the system32 directory of Windows; 3. Open php.ini and select "Windows Extensions" in the extension settings section. Add the statement "extension=php_gtk.dll" below. It is recommended to back up php.ini first to avoid modification failure and invalidating the established PHP operating environment; Now the PHP/GTK operating environment has been established. Of course, you can skip the second step and add "dl(php_gtk.dll)" to the first line of each PHP/GTK program source code to dynamically load GTK support. If you have not set up a PHP running environment, then the installation should be simpler: 1. Download the entire PHP/GTK bundled support package, and then unzip them to the PHP4 directory on the c drive; 2. Copy the dll file under the winnt directory. Go to the system32 directory of Windows and copy the php.ini file to the Windows directory; After establishing the PHP/GTK operation, you can use PHP in the command line mode to run a PHP/GTK program: Enter "c" during operation. :php4php -q gtkprogrampath", where "c:php4php" is changed to the path of PHP.EXE, and "gtkprogrampath" is the path of the PHP/GTK program. For example: "c:php4php -q c:php4sampleshello.php" will run the sample "hello world" program included in the PHP/GTK runtime package. 2. Compile a PHP/GTK program: If you make a PHP/GTK application and need the other party's computer to set up a PHP operating environment and use the PHP command line mode to parse it before it can be executed, it would be too complicated. So how can you compile a PHP/GTK program? After some searching, the author discovered the software PHPCompiler. PHPCompiler is developed by www.deskcode.com (http://www.deskcode.com/phpcompiler). It can compile PHP into an EXE executable file and has built-in PHP support. If you want to compile a PHP/GTK program, you must create PHP/GTK operating environment (refer to the previous steps). The steps to compile a PHP/GTK program are as follows: 1. Open PHPCompiler (as shown in the figure), select the PHP program source code you want to compile in "Script to", and select the path to the successfully compiled EXE file in "Destination"; 2 . Click the "Compile" button, and a dialog box will pop up asking for the compilation mode to use (if it is a PHP/GTK program, select no, if it is a simple PHPCGI program, select yes); 3. Then a dialog box will pop up asking whether to copy. php4ts.dll file to the directory of the compiled EXE file, select yes. After the above steps, a PHP/GTK program has been successfully compiled. However, there are several points that need to be paid attention to when compiling a PHP/GTK program: 1. If the compiled executable file needs to be executed, the PC must have GTK Several dll files required for the running environment (the ones downloaded earlier), if you need to make an application, you can copy several dll files to the system32 directory during installation (but this way the subroutine is not "green" Software”^_^). 2. PHPCompiler itself has very good support for PHP, but some people have tried to use some functions that require extended support, such as "gzopen", etc., which worked fine before compilation, but cannot be used after compilation. In fact, the compiled executable file is equivalent to only the default PHP support (not even GTK support), so if any function that requires extended support is applied in the program, the dll file that supports the function must be dynamically loaded. , such as "dl(php_gtk.dll)", so that no errors will occur after the compilation is completed. 3. When running a compiled executable file, a DOS window will pop up first and then close automatically. Because each GUI window is "drawn" by GTK, there must be that window. 4. Perhaps PHP could not be said to be a true OOP (object-oriented programming) language before, but with PHP/GTK, every window is "drawn" by GTK objects. Without strong OOP skills, it is difficult to write a GUI. procedural. 3. PHP/GTK resources: 1. http://gtk.php.net: The official website of PHP/GTK; although it is said to be an official website, it is indeed very simple. There is a FAQ and mailing list, and it is almost impossible to find it. Anything useful, 2. http://www.phpgtk.com: A PHP/GTK website with a better interface and the latest version information. 3. http://developer.gnome.org/doc/API/gtk/gtkobjects.html: A comprehensive/manual website for PHP/GTK functions and classes, which contains a wealth of PHP/GTK information. 4. http://www.phpuk.org/gtk/: The unofficial version of the GTK manual website, which is simple and easy to understand.If you think E-texts are ugly, you can also go to zphp.com to download the latest PHP/GTK operating environment and support package

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/531697.htmlTechArticleIn the past, PHP was considered to be only used to write server-side CGI programs. If PHP can develop GUI under Windows ( Graphical user interface) program, do you believe it? Recently, the PHP development team successfully...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn