in the function table, you need to force those parameters to be passed by reference.
PHP_FE(ncurses_getyx, first_and_second__args_force_ref) For an example of this, take a look at the headers_sent function entry in ext/standard/basic_functions.c --Wez. On Wed, 4 Jun 2003, Hans Zaunere wrote: > > Hello, > > Please forgive me if this question is redundant, but I've searched high and > low to no avail. > > As a PHP extension, I'm writing a ZEND_FUNCTION(myfunc) that needs to accept > two variables from PHP land, fill in two values (longs) and then return TRUE > or FALSE. Briefly: > > > ZEND_FUNCTION(ncurses_getyx) > { > zval *z_y,*z_x; > > if( ZEND_NUM_ARGS() != 2 ) > WRONG_PARAM_COUNT; > > if( zend_parse_parameters(2 TSRMLS_CC, "zz",&z_y,&z_x) == FAILURE ) > RETURN_FALSE; > > ZVAL_LONG(z_y,123); > ZVAL_LONG(z_x,321); > > RETURN_TRUE; > } > > > So, simple enough, this works, called, for example, like so from PHP: > > $myy = 0; > $myx = 0; > ncurses_getyx($myy,$myx); > > However, when I don't initialize $myy and $myx to 0 in PHP, I get "Notice - > Undefined variable: " errors. While I understand why it would happen, I'd > like my function to act, for instance, like exec(). exec() will accept > arguments to fill in, and even if they've never been initialized anywhere, no > such notice will be thrown. getmxrr() acts in a similar way. > > I've looked at the code for both of these functions: > > http://lxr.php.net/source/php4/ext/standard/exec.c#192 > http://lxr.php.net/source/php4/ext/standard/dns.c#708 > > but cannot see anything significant that would incur such different behavior > from that of my function. I've played around with zval_dtor(), which is used > in exec(), but still without any luck. Any help is appreciated. > > Hans > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php