ben olsam şöyle yazardım
<?
class baglanti{
    private $dbHost = "localhost"; // Host
    private $dbAdi = "yeni"; // Database Adı
    private $dbKull = "root"; // Database Kullanıcı
    private $dbSif = "root"; // Database Sifre
    function __construct($dbHost='',$dbAdi='',$dbKull='',$dbSif=''){
        if($dbHost!=''){
                $this->dbhost=$dbHost;
        }
        if($dbAdi!=''){
                $this->dbAdi=$dbAdi;
        }
        if($dbKull!=''){
                $this->dbKull=$dbKull;
        }
        if($dbSif!=''){
                $this->dbSif=$dbSif;
        }
        mysql_connect($this->dbHost,$this->dbKull,$this->dbSif) or die("Baglanti Kurulamadi!");
        mysql_select_db($this->dbadi) or die("Database secilemedi!");
    }
    function __destruct(){
        mysql_close();
    }
    function setDbHost($dbHost){
          $this->dbHost = $dbHost;
    } 
    function getDbHost(){
          return $this->dbHost;
    } 

    function setDbAdi ($dbAdi){
          $this->dbAdi = $dbAdi;
    } 
    function getDbAdi(){
          return $this->dbAdi;
    } 

    function setDbKull($dbKull){
          $this->dbKull = $dbKull;
    } 
    function getDbKull(){
          return $this->dbKull;
    } 

    function setDbSif($dbSif){
          $this->dbSif = $dbSif;
    } 
    function getDbSif (){
          return $this->dbSif;
    } 
}
?>
getter / setteri da var

arada küçük farklılıklar göreceksiniz ama ince nüanslar var