The tutorial is this: hxxp://www.osix.net/modules/article/?id=585
At this point I have prepared all the includes and paths, I have been able to build the dll but nothing is shown about my test extension in phpinfo(), also I cant use test functions defined on my test extension. I have added the extension to extensions directory in PHP and added "extension=php_extend.dll" on php.ini.
After building on VS I receive 7 warnings and 0 errors, the tutorial says some warnings are not important.
Source code follows:
php_extend.h
- Code: Select all
#define ZEND_WIN32
#define PHP_WIN32
#define ZEND_DEBUG 0
#define COMPILE_DL_EXTEND 1
#define ZTS 1
#include "php.h"
php_extend.c
- Code: Select all
#include "php_extend.h";
ZEND_FUNCTION(myfirstfunc);
ZEND_FUNCTION(myfirstfunc2);
PHP_MINFO_FUNCTION(extend);
zend_function_entry extend_functions[] = {
ZEND_FE(myfirstfunc, NULL)
ZEND_FE(myfirstfunc2, NULL)
{NULL, NULL, NULL}
};
zend_module_entry extend_module_entry = {
STANDARD_MODULE_HEADER,
"My first PHP Extension",
extend_functions,
NULL, NULL, NULL, NULL,
PHP_MINFO(extend),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#if COMPILE_DL_EXTEND
ZEND_GET_MODULE(extend)
#endif
PHP_MINFO_FUNCTION(extend) {
php_info_print_table_start();
php_info_print_table_header(2, "Extend the amazing php extension", "");
php_info_print_table_row(2, "PHP Extension", "enabled");
php_info_print_table_end();
}
ZEND_FUNCTION(myfirstfunc) {
zend_printf("This is my first function");
}
ZEND_FUNCTION(myfirstfunc2) {
zend_printf("This is my second function");
}
Output Window:
- Code: Select all
Compiling...
php_extend.c
php_extend.c(1) : warning C4067: unexpected tokens following preprocessor directive - expected a newline
c:\build\Zend\zend_execute.h(92) : warning C4311: 'type cast' : pointer truncation from 'void *' to 'ulong'
c:\build\Zend\zend_execute.h(104) : warning C4311: 'type cast' : pointer truncation from 'void *' to 'ulong'
php_extend.c(29) : warning C4013: 'php_info_print_table_start' undefined; assuming extern returning int
php_extend.c(30) : warning C4013: 'php_info_print_table_header' undefined; assuming extern returning int
php_extend.c(31) : warning C4013: 'php_info_print_table_row' undefined; assuming extern returning int
php_extend.c(32) : warning C4013: 'php_info_print_table_end' undefined; assuming extern returning int
Results:
- Code: Select all
extend - 0 error(s), 7 warning(s)
I had to fix some errors in the tutorials code, there are some " & # 8 2 2 1 ; " (without spaces) things, I have replaced those with ", perhaps I misssed some other fixes.
Hope you can help, thanks in advance ;)




... I think it can be something I´m missing on the VS .NET 2003 configuration.
