Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:2163 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15669 invoked from network); 4 Jun 2003 16:29:04 -0000 Received: from unknown (HELO secure.thebrainroom.com) (213.239.42.171) by pb1.pair.com with SMTP; 4 Jun 2003 16:29:04 -0000 Received: from zaneeb.brainnet.i (IDENT:root@brain.dial.nildram.co.uk [195.149.29.154]) by secure.thebrainroom.com (8.9.3/8.9.3) with ESMTP id RAA15469; Wed, 4 Jun 2003 17:29:01 +0100 Received: from zaneeb.brainnet.i (IDENT:wez@zaneeb.brainnet.i [127.0.0.1]) by zaneeb.brainnet.i (8.11.6/8.11.6) with ESMTP id h54GT1824481; Wed, 4 Jun 2003 17:29:02 +0100 Date: Wed, 4 Jun 2003 17:29:01 +0100 (BST) X-X-Sender: wez@zaneeb.brainnet.i To: Hans Zaunere cc: internals@lists.php.net In-Reply-To: <20030604142631.9449.qmail@web12803.mail.yahoo.com> Message-ID: References: <20030604142631.9449.qmail@web12803.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Undefined variables as extension args From: wez@thebrainroom.com (Wez Furlong) 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 > > >