Are objects in PHP passed by value or reference?

前端 未结 3 950
栀梦
栀梦 2020-12-02 01:22

In this code:

setValue($value);
    }

    function setValue($value)
          


        
3条回答
  •  失恋的感觉
    2020-12-02 02:06

    They are passed by value in PHP 4 and by reference in PHP 5. In order to pass objects by reference in PHP 4 you have to explicitly mark them as such:

    $obj = &new MyObj;
    

提交回复
热议问题