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.

 - Brad

--- "Tim Daly, Jr." <[EMAIL PROTECTED]> wrote:
> 
> I'm trying to do some extension programming, and I'm pretty confused
> by the whole zval thing.  In particular, references are a little
> mysterious.  If I have
> 
>         $foo = "zonk";
>         $bar =& $foo;
> 
> in PHP, what actually happens?  Specifically, if I wanted a function
> that did such a reference assignment:
> 
>         $foo = "zonk";
>         $bar = "baz";
> 
>         ref_assign($bar, $foo); // $bar =& $foo;
> 
> what has to happen in ref_assign?
> 
> Thanks,
> Tim
> 
> 
> -- 
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to