Undefined variables as extension args

From: Date: Wed, 04 Jun 2003 14:26:31 +0000
Subject: Undefined variables as extension args
Groups: php.internals 
Request: Send a blank email to internals+get-2158@lists.php.net to get a copy of this message
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

« previous php.internals (#2158) next »