| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             [2001-11-17 13:01 UTC] mfischer@php.net
  | 
    |||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 07:00:01 2025 UTC | 
here is my script: <?php 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) { $bug->add($f); return($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); $bug->spew(); ?> 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 otherwise? thanks, tonys.