擴(kuò)展你的 PHP 之入門篇
擴(kuò)展你的php
首先注意,以下所有的一切皆在 win 下進(jìn)行,使用的工具的 VC++6.0。
擴(kuò)展你的PHP
PHP以方便快速的風(fēng)格迅速在web系統(tǒng)開發(fā)中占有了重要地位. PHP本身提供了豐富的大量的函數(shù)及功能. 長話短說. 我們看看我們?nèi)绾芜M(jìn)行擴(kuò)展.
擴(kuò)展的3種方式
- External Modules
- Built-in Modules
- The Zend Engine
3 種方式的優(yōu)缺點(diǎ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、打開 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、寫代碼.
建個(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
ZEND_GET_MODULE(binzy)
#endif
function_entry binzy_functions[] = {
PHP_FE(hellobinzy, NULL)
{NULL, NULL, NULL}
};
zend_module_entry binzy_module_entry = {
STANDARD_MODULE_HEADER,
"binzy", binzy_functions, NULL, NULL, NULL, NULL, PHP_MINFO(binzy), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES
};
PHP_MINFO_FUNCTION(binzy)
{
php_info_print_table_start();
php_info_print_table_row(2, "Binzy Extension", "Enable");
php_info_print_table_end();
}
PHP_FUNCTION(hellobinzy)
{
zend_printf("Hello Binzy");
}
#endif
7、編譯,修改 php.ini,restart apache,寫個(gè) php
<?php
hellobinzy();
?>
hoho~~~

phpinfo();
小結(jié)
這算入門篇, 以后再一步步來~~. 慢慢深入, 有些我也不了解的。 偶是初學(xué)者。
相關(guān)文章
原生php實(shí)現(xiàn)excel文件讀寫的方法分析
這篇文章主要介紹了原生php實(shí)現(xiàn)excel文件讀寫的方法,結(jié)合實(shí)例形式分析了采用原生php針對(duì)Excel進(jìn)行讀寫操作的相關(guān)實(shí)現(xiàn)方法與操作注意事項(xiàng),需要的朋友可以參考下2018-04-04
整理的一些實(shí)用WordPress后臺(tái)MySQL操作命令
WordPress將其所有信息片段(包括文章、頁面、評(píng)論、博客鏈接、插件設(shè)置等)存儲(chǔ)在MySQL數(shù)據(jù)庫中。 雖然WordPress用戶可以通過網(wǎng)站后臺(tái)編輯控制以上信息片段2013-01-01
PHP 防注入函數(shù)(格式化數(shù)據(jù))
下面的函數(shù)通過格式化數(shù)據(jù)的方法實(shí)現(xiàn)數(shù)據(jù)的addslashes,不過也建議大家參考下discuz的防注入函數(shù)。2011-08-08
php中通過Ajax如何實(shí)現(xiàn)異步文件上傳的代碼實(shí)例
php結(jié)合Ajax技術(shù)如何實(shí)現(xiàn)異步文件上傳 有了file filereader 對(duì)象的支持,異步文件上傳將變得簡單。(以前都會(huì)把form提交到iframe來實(shí)現(xiàn))2011-05-05








