擴展你的php
首先注意,以下所有的一切皆在 win 下進行,使用的工具的 VC++6.0。
擴展你的PHP
PHP以方便快速的風格迅速在web系統開發中占有了重要地位. PHP本身提供了豐富的大量的函數及功能. 長話短說. 我們看看我們如何進行擴展.
擴展的3種方式
3 種方式的優缺點可參見 PHP 手冊:http://www.php.net/manual/en/zend.possibilities.php
extension dll
1、首先我們去下個 php 的 source. 可以看到有以下幾個重要的目錄。ext,main,TSRM,Zend,另外我們可能還需要 bindlib_w32(需要你從 cvs 上下),及 PHP 目錄下的 php4ts.lib。
2、打開 VC,新建一個 Win32 Dynamic-Link Library,如下圖:
3、點 ok,選擇“An Empty Dll Project”,點擊完成。
4、設置 Build 的 Active Configuration,選 Release:)
5、Project->settings
預定義標識. 整個如下:
ZEND_DEBUG=0, COMPILE_DL_BINZY, ZTS=1, ZEND_WIN32, PHP_WIN32, HAVE_BINZY=1
這個是包含路徑,上面所提及的幾個路徑都可以加入。
選擇 Multithreaded DLL。
取名時隨便的,要 link php4ts.lib~~
o,忘了,別忘了加上 /Tc 的參數:
6、寫代碼.
建個頭,建個身體。
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
新聞熱點
疑難解答