《PHP實例:詳解Window7 下開發php擴展》要點:
本文介紹了PHP實例:詳解Window7 下開發php擴展,希望對您有用。如果有疑問,可以聯系我們。
一、首先查看phpinfo() 信息PHP學習
PHP Version 5.4.34
Zend Extension Build API220100525,TS,VC9
PHP Extension Build API20100525,TS,VC9
Thread Safety enable
PHP學習
線程平安,VC9編譯,5.4.34版本PHP學習
二、開發前準備工作PHP學習
php 5.3-5.4 :Visual C++ 9.0(Visual Studio 2008)
安裝Cygwin(下載地址:http://www.cygwin.com/),虛擬linux環境
php編譯后的程序和編譯前的源碼(下載地址:http://windows.php.net/download/)
編譯后的程序路徑:php-5.4.45-Win32-VC9-x86\
編譯前的源碼路徑:php-5.4.45-src\
下載php sdk文件,http://windows.php.net/downloads/php-sdk/PHP學習
1、解壓php-sdk-binary-tools-20110915.zip里面的文件,將bison.exe所在的bin目錄添加的系統path中
PHP學習
將php-5.4.45-Win32-VC9-x86\dev\php5ts.lib 復制到php-5.4.45-src\Release_TS\php5ts.lib
新建php-5.4.45-src\main\config.win32.h,內容如下:
#define SIZEOF_LONG 4
#define PHP_COMPILER_ID "VC9"
"VC9"對應VC9PHP學習
2、找到php源碼目錄, php-5.4.45-src\ext\ext_skel_win32.php
PHP學習
/* This script can be used on Win systems ) Make sure you have CygWin installed ) Adjust the $cygwin_path to match your installation ) Change the environment cariable PATHEXT to include .PHP ) run ext_skel --extname=... the first time you run this script you will be asked to associate it with a program. chooses the CLI version of php. */ $cygwin_path = 'D:\Program Files\cygwin\bin';
這里改成你的cygwin安裝目錄.PHP學習
3、運行cmd,進入php源碼目錄, php-5.4.45-src\ext,運行命令php ext_skel_win32.php --extname=myphpexs
PHP學習
PHP學習
記得將php.exe 所在目錄加入path,--extname=你的擴展名字,
PHP學習
若成功會再ext目錄下生成myphpexs文件夾,內容如下
PHP學習
PHP學習
4、用vs2008 打開myphpexs.dsp, 辦理方案配置改為Release,執行生成命令
PHP學習
順利的話將生成php_myphpexs.dll文件,我的將php_myphpexs.dll生成再了php源碼根目錄的Release_TS文件夾中PHP學習
5、將php_myphpexs.dll放到你php的擴展目錄,再php.ini中加上extension=php_myphpexs.dll
PHP學習
6、新建php腳本文件test.php,內容如下
PHP學習
7、運行測試文件,出現如下內容說明,成功了 PHP學習
8、confirm_myphpexs_compiled是建立擴展是自帶的冊數函數,在編輯你本身的擴展內容時,可以刪除改函數PHP學習
《PHP實例:詳解Window7 下開發php擴展》是否對您有啟發,歡迎查看更多與《PHP實例:詳解Window7 下開發php擴展》相關教程,學精學透。維易PHP學院為您提供精彩教程。