Are PHP5 objects passed by reference?

后端 未结 8 763
抹茶落季
抹茶落季 2020-11-27 03:45

I can\'t seem to get any consistent info on this. Different sources appear to say different things and the venerable php.net itself (appears) not to explicitly stat

8条回答
  •  遥遥无期
    2020-11-27 04:37

    Here's another example confirming that objects are passed by reference.

    foo++;
        }
    }
    
    $objA = new A();
    $objB = new B();
    $objB->inc($objA);
    
    echo "[" . $objA->foo . "]"; // Outputs [2]
    

提交回复
热议问题