[b]扩展你的php[/b]
[list=1]
[*][b][url=http://www.openphp.cn/index.php?module=article&id=120#1]扩展你的php[/url][/b]
[/*][*][b][url=http://www.openphp.cn/index.php?module=article&id=120#2]扩展的3种方式[/url][/b]
[/*][*][b][url=http://www.openphp.cn/index.php?module=article&id=120#3]extension dll方式的扩展[/url][/b]
[/*][*][b][url=http://www.openphp.cn/index.php?module=article&id=120#4]小结[/url][/b][/*][/list]
首先注意,以下所有的一切皆在 win 下进行,使用的工具的 VC++6.0。
[b]扩展你的PHP[url=http://www.php.net/manual/en/zend.possibilities.php]http://www.php.net/manual/en/zend.possibilities.php[/url]
[b]extension dll[url=http://www.openphp.cn/PCKeditor/userimages/2004102605.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102605.gif[/img]
[/url]
3、点 ok,选择“An Empty Dll Project”,点击完成。
4、设置 Build 的 Active Configuration,选 Release:)
[url=http://www.openphp.cn/PCKeditor/userimages/2004102606.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102606.gif[/img]
[/url]
5、Project->settings
[url=http://www.openphp.cn/PCKeditor/userimages/2004102607.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102607.gif[/img]
[/url]
预定义标识. 整个如下:
ZEND_DEBUG=0, COMPILE_DL_BINZY, ZTS=1, ZEND_WIN32, PHP_WIN32, HAVE_BINZY=1
[url=http://www.openphp.cn/PCKeditor/userimages/2004102608.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102608.gif[/img]
[/url]
这个是包含路径,上面所提及的几个路径都可以加入。
[url=http://www.openphp.cn/PCKeditor/userimages/2004102609.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102609.gif[/img]
[/url]
选择 Multithreaded DLL。
[url=http://www.openphp.cn/PCKeditor/userimages/2004102610.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102610.gif[/img]
[/url]
取名时随便的,要 link php4ts.lib~~ [img]http://www.openphp.cn/PCKeditor/images/smiley/fun/cool.gif[/img]
o,忘了,别忘了加上 /Tc 的参数:
[url=http://www.openphp.cn/PCKeditor/userimages/2004102611.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102611.gif[/img]
[/url]
6、写代码.
建个头,建个身体。
[b]Binzy.h[/b]
// 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
[b]Binzy.c[/b]
// 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,写个 php
<?php
hellobinzy();
?>
hoho~~~
[img]http://www.openphp.cn/PCKeditor/userimages/2004102612.gif[/img]
phpinfo();
[url=http://www.openphp.cn/PCKeditor/userimages/2004102613.gif][img]http://www.openphp.cn/PCKeditor/userimages/2004102613.gif[/img]
[/url]
[b]小结
[/b]
这算入门篇, 以后再一步步来~~. 慢慢深入, 有些我也不了解的。 偶是初学者。