/ ** Copyright belongs to PHPSALON.COM, unauthorized, it is strictly forbidden to reprint ** Author: wenlong wu * /
First, ready to work:
Development Environment: To compile PHP you need Microsoft development environment. It is recommended to use Microsoft Visuaul C 6.0, of course, Microsoft Visuaul C . Net is also possible. Other Tools: If you use the automatically generated PHP extension code, you also need a Cygwin to run the environment. To install Bison, Flex, AWK and other tools. PHP Source Code: You can download the latest release of the source code from the PHP official website, of course, you can also get the latest development version by anonymous CVS. This article assumes the PHP source package is placed in D: /EZAPP/php-4.3 .7 directory. Compiling the files required to develop PHP extensions, such as php4ts.lib, php.exe, etc., of course, can be copied from the compiled bag.
Second, generate a frame:
A source code framework that automatically generates a PHP extension can be accelerated in the PHP source code package. Enter the command line mode, execute the following command (this article assumes an extension called MyEXT): CD D: /ezapp/php-4.3.7/ext ../release_ts/php-cli.exe ext_skel_win32.php --extName = After myEXT executs the above command, the directory named myext will automatically create a directory in the ext directory. The files inside are the full frame of the extended source code, and the extension can now be compiled. MSDEV myext / myext.dsp / make "myext - win32 release_ts" After completing the completion of the D: /EZAPP/PHP-4.3.7/Release_TS directory. Copy this file to your PHP directory (such as: c: / php / extension) and add extension = myext.dll in php.ini, then follow the web server, now open the browser to enter http: // localhost /myext.php Browse the result (assuming that the MyExt.php file has been copied to the web root directory). This extension currently contains only a nameful confirm_extName_compiled function.
Third, join your code:
Here to add a parameter HELLO function, the operation steps are as follows:
Open the php_myext.h file, add a statement, as shown in Figure 1:
(Figure 1)
Open myExt.c file, join a custom Hello function, as shown in Figure 2:
(Figure II)
(Figure 3)
Re-compile myExt msdev myext / myext.dsp / make "myext - win32 release_ts" copy myext.dll file into your PHP extension (such as: C: / PHP / EXTENSION), and restart the web server. New Hello.php file, the content is as follows, open the browser to run Phphello ("ez development team");> The screen will be output: Hello Ez Development Team IV, post
This article is only an entry-level article, aimed at bringing you to the ranks of PHP expansion development, and I will also write some advanced development articles, so stay tuned.