Hello,
I try to write an extension to php5 on a Windows XP-system using Visual C++ 2008
I succeeded in compiling the "skeleton" extension as a DLL.
I can load it into php.
I can see its exported functions with "php --re extname"
Extension [ <persistent> extension #52 extname version 0.1 ] {
- Functions {
Function [ <internal:extname> function confirm_extname_compiled ] {
}
}
BUT:
I dont get any output:
php -r "confirm_extname_compiled('A');" outputs only an empty line.
As php -r "confirm_extname_compiled();" gives a warning about the missing parameter to confirm_extname_compiled(), I'm pretty sure, the function gets called.
The .h and .c file ist attached...
What might be wrong??
Thanks in advance for any hints!
Gerhard
problem writing an extension
Moderator: General Moderators
-
gerhard_wien
- Forum Newbie
- Posts: 3
- Joined: Thu Jan 14, 2010 9:44 am
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: problem writing an extension
I don't see any code attached. What does the function print/return?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
gerhard_wien
- Forum Newbie
- Posts: 3
- Joined: Thu Jan 14, 2010 9:44 am
Re: problem writing an extension
Sorry, somehow I made an mistake when uploading...
I'll try again. Anyhow, here is the function:
I tried a "simpler" version:
It dosn't wor either.
Gerhard
I'll try again. Anyhow, here is the function:
Code: Select all
PHP_FUNCTION(confirm_extname_compiled)
{
char *arg = NULL;
int arg_len, len;
char string[256];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
return;
}
len = sprintf(string, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "extname", arg);
RETURN_STRINGL(string, len, 1);
}Code: Select all
PHP_FUNCTION(say_hello)
{
RETURN_STRING("Hello World", 1);
}Gerhard
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: problem writing an extension
Your function doesn't output anything, it just returns it, so:
Code: Select all
echo confirm_extname_compiled('A');mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
gerhard_wien
- Forum Newbie
- Posts: 3
- Joined: Thu Jan 14, 2010 9:44 am
Re: problem writing an extension
Shame on me!
Thanks for your help.
Gerhard
Thanks for your help.
Gerhard