From:             [EMAIL PROTECTED]
Operating system: FreeBSD 4.1 RELEASE
PHP version:      4.0.4
PHP Bug Type:     Class/Object related
Bug description:  object reference vs. true object function passing problem

here is my script:


class Tbug {
    function add($f) {
        $this->stuff[] = $f;
    function spew() {
        foreach($this->stuff as $key => $f) echo "stuff is [$f]<BR>";

function & addtobug($f, &$bug) {

// using first choice we have problems, second choice works, why the diff?

//$bug = new Tbug();
$bug = &new Tbug();

echo "call1<BR>";
$bug = &addtobug("a", &$bug);
echo "call2<BR>";
$bug = &addtobug("b", &$bug);
echo "call3<BR>";
$bug = &addtobug("c", &$bug);

The "work around" is to use the second choice of assigning $bug to the reference of 
the "new" Object.  This does not seem inuitive to me.  Why does this code not work 



Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to