Created
May 15, 2013 09:46
-
-
Save ruliarmando/5582833 to your computer and use it in GitHub Desktop.
abstract class using PHP 5
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 | |
abstract class Ayam{ | |
public abstract function berjenisKelamin(); | |
} | |
class AyamJantan extends Ayam{ | |
public function berjenisKelamin(){ | |
echo "jantan"; | |
} | |
} | |
class AyamBetina extends Ayam{ | |
public function berjenisKelamin(){ | |
echo "betina"; | |
} | |
} | |
$ayamjantan = new AyamJantan(); | |
$ayambetina = new AyamBetina(); | |
$ayam = $ayamjantan; | |
echo $ayam->berjenisKelamin(); | |
$ayam = $ayambetina; | |
echo $ayam->berjenisKelamin(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment