Quick actions

cmd+k|ctrl+k

Navigation

Languages

__Constructor

Snippet info

Language

Php

Visibility

public

Author

alfrenzaburhannudin

Created

2024-02-12T09:00:53.758082Z

Updated

2024-02-15T09:41:21.535483Z

<?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);
INFO