//pseudo code $GLOBALS['obj'] = new myObj(); // create my object global $obj; // make it global? $obj->set_env($value); // works fine function test { $obj->set_env($value2); // Doesn't work, produces below error. } //error: Fatal error: Call to a member function set_env() on a non-object // test() is called from inside another function.