Created
June 18, 2017 22:44
-
-
Save bigkiandi/ab774ca6ae3019a29eb305749e934e28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// buat class komputer | |
class komputer { | |
// property dengan hak akses protected | |
protected $jenis_processor = "Intel Core i7-4790 3.6Ghz"; | |
} | |
// buat class laptop | |
class laptop extends komputer{ | |
public function tampilkan_processor() { | |
return $this->jenis_processor; | |
} | |
} | |
// buat objek dari class laptop (instansiasi) | |
$laptop_baru = new laptop(); | |
// jalankan method | |
echo $laptop_baru->tampilkan_processor(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class leptop { | |
// buat properti untuk class leptop | |
var $pimilik | |
// buat method | |
function idupinLeptop() | |
{ | |
return "NYALA"; | |
} | |
} | |
// buat object dari class leptop | |
$leptop_andi = new leptop(); | |
// set property | |
$leptop_andi->pemilik = "ANDI"; | |
// tampilkan property di browser | |
echo $leptop_andi->pemilik; | |
echo $leptop_andi->idupinLeptop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment