Skip to content

Instantly share code, notes, and snippets.

@Majkl578
Created July 27, 2010 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Majkl578/492348 to your computer and use it in GitHub Desktop.
Save Majkl578/492348 to your computer and use it in GitHub Desktop.
<?php
class Foo
{
public $bar;
public function __construct()
{
$this->update(5);
}
public function update($x)
{
$this->bar = new Bar;
$this->bar->x = $x;
}
public function &getBar()
{
return $this->bar;
}
}
class Bar
{
public $x;
}
$foo = new Foo;
$bar =& $foo->getBar();
var_dump($bar->x);
$foo->update(11);
var_dump($bar->x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment