Re: trying to understand zvals

From: Date: Thu, 17 Oct 2002 16:34:16 +0000
Subject: Re: trying to understand zvals
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-89667@lists.php.net to get a copy of this message
Brad LaFountain <rodif_bl@yahoo.com> writes: > PHP_FUNCTION(ref_assign) > { > zval *bar, *foo; > > if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &bar, &foo) == > FAILURE) { > return; > } > > ZVAL_ADDREF(foo); > *bar = *foo; > bar->is_ref = TRUE; > bar->refcount = 1; > } > > this works, but i don't know if its the best way to do it. > Thanks, but it doesn't actually work for me. Witness: [tim@myst php-4.2.3]$ ./php -f ext/foo/foo.php foo foo baz -*- ^@\204Í FATAL: erealloc(): Unable to allocate 1515870811 bytes Segmentation fault (core dumped) [tim@myst php-4.2.3]$ ext/foo/foo.php contains: <? if(!extension_loaded('foo')) { dl('foo.so'); } //make two variables $foo = "foo"; $bar = "zonk"; //reference assignment $bar =& $foo; //should be identical echo "$foo\n"; echo "$bar\n"; //set foo and bar to "baz" $bar = "baz"; //should print "baz" echo "$foo\n"; echo "-*-\n"; //make two variables $wibb = "foo"; $wobb = "zonk"; //reference assignment ref_assign($wobb, $wibb); //set wibb and wobb to "baz" echo "$wibb\n"; echo "$wobb\n"; //should print "baz" $wobb = "baz"; echo "$wibb\n"; ?> -Tim

« previous php.dev (#89667) next »