#php #pemograman-berorientasi-objek-di-php #dasar-pemograman-berorientasi-objek-pbo-di-php
Petunjuk Diskusi
class handphone {
public $kamera;
public $tahun;
public $layar_sentuh = true;
public function __construct($kamera, $tahun){
$this->kamera = $kamera;
$this->tahun = $tahun;
}
public function ambil_foto(){
return "$this->kamera jepret..!!";
}
}
$canggih = new handphone ("8 Megapixels", 2013);
$jadul = new handphone ("2 Megapixels", 2012);
$jadul->layar_sentuh = false;
echo $canggih->ambil_foto();
1 jempol
ZihxS
300
816
·
7 tahun, 9 bulan yang lalu
·
1 jempol
class Handphone {
public $kamera;
public $tahun;
public $layar_sentuh = true;
public function __construct($kamera,$tahun){
$this->kamera = $kamera;
$this->tahun = $tahun;
}
public function ambil_photo() {
return "$this->kamera jepret..!!";
}
public function tahun_hp() {
return "HP Ini tahun $this->tahun";
}
}
$canggih = new Handphone("Kamera : 8 Megapixels","Tahun : 2013");
$jadul = new Handphone("Kamera : 2 Megapixels","Tahun : 2012");
$jadul->layar_sentuh = false;
echo $canggih->ambil_photo();
echo $jadul->tahun_hp();
cybersec
211
2
·
7 tahun, 5 bulan yang lalu
·
0 jempol
//perasaan gw di soal kaga ada disuruh cetak tahun hp nya
//jd gw cukup gini aja jalan ko..
//jgn lupa perhatiin setelah notasi panah ngga ada lg tanda "$"
class Handphone {
public $kamera;
public $tahun;
public $layar_sentuh = true;
public function __construct($kamera, $tahun) {
$this->kamera=$kamera;
$this->tahun=$tahun;
}
public function ambil_photo() {
return "$this->kamera jepret..!!";
}
}
$canggih = new Handphone("Kamera: 8 Megapixels", "Tahun : 2013");
$jadul = new Handphone("Kamera: 2 Megapixels", "Tahun : 2012");
$jadul->layar_sentuh=false;
echo $canggih->ambil_photo();
AlGhifari1337
208
4
·
7 tahun, 5 bulan yang lalu
·
0 jempol
@cybersec emang codenya sudah benar tapi kan gaada salahnya berkreatif dikit seperti om ZihxS. hehe....