<?php
class Produk {
public $judul;
public $penulis;
public $penerbit;
public $harga;
public function __construct($judul = "judul", $penulis = "penulis", $penerbit = "penerbit", $harga = 0){
$this->judul = $judul;
$this->penulis=$penulis;
$this->penerbit=$penerbit;
$this->harga=$harga;
}
public function getLable(){
return "$this->penulis, $this->penerbit, $this->judul, $this->harga";
}
}
$produk1 = new Produk("Naruto", "Masashi Kihsimoto", "Shonen Jump", "35000");
$produk2 = new Produk("Harry Potter", "Jk Rowling", "Warner Bross", "250000");
$produk3 = new produk("Dragon Ball");
echo $produk1->getLable();
echo $produk2->getLable();
var_dump($produk3);
<?php
class Coba {
public $property; //property
public function fungsi(){
} //method
}
$a = new Coba();
$b = new Coba();
var_dump($a);
var_dump($b);