dbname = $GLOBALS['dbname']; echo $this->dbname; } } $obj = new db(); $obj->test( );