$b = "aaa"; function a() { global $b; $a = new stdClass(); $b = &$a; } a(); var_dump($b); // why is $b "aaa" at the end?