Hallo.
I need to create custom extension for PHP. All things are going well till I want to load compiled extension into PHP. Than I’m getting this error message (by using php -m):
“Warning: PHP Startup: Invalid library (maybe not a PHP library) ‘first.so’ in Unknown on line 0”
Does anybody see any mistake in my source code below? Thank U for hellp.
config.m4:
[code]PHP_ARG_ENABLE(first,whether to enable FIRST functions,
[ --disable-first Disable FIRST functions], yes)
if test “$PHP_FIRST” = “yes”; then
AC_DEFINE(HAVE_FIRST, 1, [whether to include FIRST functions])
PHP_NEW_EXTENSION(first, first.c, $ext_shared)
fi
[/code]
first.c:
[code]#ifdef HAVE_CONFIG_H
#include “config.h”
#endif
#include “php.h”
#include “ext/standard/info.h”
extern zend_module_entry first_module_entry;
#define first_module_ptr &first_module_entry
#define phpext_first_ptr first_module_ptr
static PHP_MINFO_FUNCTION(first)
{
php_info_print_table_start();
php_info_print_table_row(2, “Revision”, “$Id: 01 $”);
php_info_print_table_end();
}
static PHP_MINIT_FUNCTION(first)
{
return SUCCESS;
}
PHP_FUNCTION(hallo)
{
RETURN_STRING(“FIRST extension function works\n”, 1);
}
ZEND_BEGIN_ARG_INFO_EX(arginfo_hallo, 0, 0, 0)
ZEND_END_ARG_INFO()
const zend_function_entry first_functions[] = {
PHP_FE(hallo, arginfo_hallo)
PHP_FE_END
};
zend_module_entry first_module_entry = {
STANDARD_MODULE_HEADER,
“first”,
first_functions,
PHP_MINIT(first),
NULL,
NULL,
NULL,
PHP_MINFO(first),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_POSIX
ZEND_GET_MODULE(first)
#endif
[/code]