fork download
  1. <?php
  2.  
  3. class TestClass {
  4. public $hello = '';
  5. }
  6.  
  7. function modify(&$obj) {
  8. $obj = 42;
  9. }
  10.  
  11. $obj = new TestClass();
  12. $obj->hello = 'world';
  13.  
  14. modify($obj);
  15.  
  16. var_dump($obj); // outputs "42"
  17.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
int(42)