擴(kuò)展你的php
首先注意,以下所有的一切皆在 win 下進(jìn)行,使用的工具的 VC++6.0。
擴(kuò)展你的PHP
PHP以方便快速的風(fēng)格迅速在web系統(tǒng)開(kāi)發(fā)中占有了重要地位. PHP本身提供了豐富的大量的函數(shù)及功能. 長(zhǎng)話短說(shuō). 我們看看我們?nèi)绾芜M(jìn)行擴(kuò)展.
擴(kuò)展的3種方式
3 種方式的優(yōu)缺點(diǎn)可參見(jiàn) PHP 手冊(cè):http://www.php.net/manual/en/zend.possibilities.php
extension dll
1、首先我們?nèi)ハ聜€(gè) php 的 source. 可以看到有以下幾個(gè)重要的目錄。ext,main,TSRM,Zend,另外我們可能還需要 bindlib_w32(需要你從 cvs 上下),及 PHP 目錄下的 php4ts.lib。
2、打開(kāi) VC,新建一個(gè) Win32 Dynamic-Link Library,如下圖:

3、點(diǎn) ok,選擇“An Empty Dll Project”,點(diǎn)擊完成。
4、設(shè)置 Build 的 Active Configuration,選 Release:)

5、Project->settings

預(yù)定義標(biāo)識(shí). 整個(gè)如下:
ZEND_DEBUG=0, COMPILE_DL_BINZY, ZTS=1, ZEND_WIN32, PHP_WIN32, HAVE_BINZY=1

這個(gè)是包含路徑,上面所提及的幾個(gè)路徑都可以加入。

選擇 Multithreaded DLL。

取名時(shí)隨便的,要 link php4ts.lib~~
o,忘了,別忘了加上 /Tc 的參數(shù):

6、寫(xiě)代碼.
建個(gè)頭,建個(gè)身體。
Binzy.h
// Binzy Wu
// 2004-4-9
// PHP Extension
#if HAVE_BINZY
extern zend_module_entry binzy_module_entry;
#define binzy_module_ptr &binzy_module_entry
PHP_FUNCTION(hellobinzy); //
PHP_MINFO_FUNCTION(binzy); //
#endif
Binzy.c
// Binzy Wu
// 2004-4-9
// PHP Extension
#include "php.h"
#include "Binzy.h"
#if HAVE_BINZY
#if COMPILE_DL_BINZY
新聞熱點(diǎn)
疑難解答