Re: Help creating a new extension

From: Date: Sun, 11 May 2003 22:42:18 +0000
Subject: Re: Help creating a new extension
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-5310@lists.php.net to get a copy of this message
Thanks to Johannes' hint, I was able to compile my extension into PHP: Functions available in the test extension:<br> confirm_my_module_compiled<br> double_it<br> <br> Congratulations! You have successfully modified ext/my_module/config.m4. Module my_module is now compiled into PHP. Other than the 'confirm_my_module_compiled' function, I also put in a 'double_it' function, which has the code shown in the manual: http://www.php.net/manual/en/zend.creating.php ZEND_FUNCTION(double_it) { long parameter; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "1", &parameter) == FAILURE) { return; } RETURN_LONG( parameter ); } Currently it does not double the parameter, the code is exactly as shown and should just return whatever it was given. However, when I try to use this function, with the following php code: <?php if !extension_loaded('my_module')) { dl('my_module.so'); } $param = 2; $return = double_it( $param ); print("We sent '$param' and got '$return'"); echo phpinfo(); ?> I get: Warning: double_it(): bad type specifier while parsing parameters in /usr/local/apache2/htdocs/my_module.php on line 6 I Googled on that error message and only got one hit-- a page showing the source code that produces it. Commenting out the 'if (zend_parse...' statement and make/make install/view page again produces: We sent '2' and got '-1073760576' I'm stuck again and would appreciate another hint. Also, what is the difference between ZEND_FUNCTION (which my double_it is) and PHP_FUNCTION which confirm_my_module_compiled, added by the ext_skel script is)? Thanks in advance, again. -- Wendy Smoak Chandler, AZ (USA)

« previous php.pear.general (#5310) next »