<?php class db { var $veritabaniadi; var $link; var $hatanumarasi; var $hata; function db() { $sunucu = "localhost"; $veritabani = "php"; $kullaniciadi = "root"; $sifre = ""; $this->veritabaniadi = $veritabani; $this->link = mysqli_connect($sunucu,$kullaniciadi,$sifre,$veritabani); $this->hatanumarasi = mysqli_errno($this->link); $this->hata = mysqli_error($this->link); } function veritabaniadi() { return $this->veritabaniadi; } function link(){ return $this->link; } function hatanumarasi(){ return $this->hatanumarasi; } function hata() { return $this->hata; } } $db=new db(); $sorgu=mysqli_query($db->link(),"select * from php limit 1"); while($s=mysqli_fetch_array($sorgu)){ echo $s["id"]."<br>"; echo $db->hata."<br>"; echo $db->hatanumarasi."<br>"; echo $db->veritabaniadi; } ?>
Çıktısı
1 0 php