class c1 { public function init() { echo "inited\n"; } } function test1() { global $c; if(!isset($c)) { $c= &new c1; $c->init(); } } function test2() { global $c; if(!isset($c)) { $c= &new c1; $c->init(); } } global $c; test1(); test2(); test1();