Windows 下的 PHP 扩展编程
Jun 08, 2016 pm 05:32 PMPHP 扩展是用 C 或 C++ 编写的,需要编译成动态连接库 dll 文件后在 PHP 环境下注册后才能使用。
编写 PHP 扩展的软件要求:
VC++6.0 或 VC++.NET 环境。
PHP 的源代码,需要编译。
如果不愿意编译 PHP 的源代码,可以再下载 PHP 的已经编译成功的二进制代码(就是我们部署 PHP 运行环境的那些文件包)。注意分别下载的源文件包和已编译包,它们的版本必须一致。
过程:
1,安装 VC++6.0,并选择把其可执行文件路径加入环境变量中,使在命令行环境任意路径下可以运行编译器。
2,安装 PHP 运行环境,并与 IIS 正确集成在一起。假设使用的 PHP 版本为 5.2.5,下载 php-5.2.5-Win32.zip 二进制包和 php-5.2.5.tar.gz 源代码包。安装环境为 C:php-5.2.5-Win32。分别把源代码包和二进制包解压到该文件夹下。从 php.ini-recommended 拷贝生成一个 php.ini 文件。
3,建立 C:php-5.2.5-Win32Release_TS 文件夹,拷贝 C:php-5.2.5-Win32devphp5ts.lib 文件到这里。
4,进入 C:php-5.2.5-Win32ext 文件夹,运行命令:
C:php-5.2.5-Win32ext>..php.exe ext_skel_win32.php --extname=myphpext
Creating directory myphpext
Creating basic files: config.m4 config.w32 .cvsignore myphpext.c php_myphpext.h
CREDITS EXPERIMENTAL tests/001.phpt myphpext.php [done].
To use your new extension, you will have to execute the following steps:
1. $ cd ..
2. $ vi ext/myphpext/config.m4
3. $ ./buildconf
4. $ ./configure --[with|enable]-myphpext
5. $ make
6. $ ./php -f ext/myphpext/myphpext.php
7. $ vi ext/myphpext/myphpext.c
8. $ make
Repeat steps 3-6 until you are satisfied with ext/myphpext/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian

How To Set Up Visual Studio Code (VS Code) for PHP Development
