Last active
December 8, 2018 16:05
-
-
Save galihlprakoso/a68e0c863039709b0fd9023d3dfae361 to your computer and use it in GitHub Desktop.
galihlprakoso-com-blog-introduction-oop
This file contains hidden or 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 | |
//Contoh koding prosedural | |
$a = 20; | |
$b = 20; | |
$hasil = $a+$b; | |
echo "Hasil : ".$hasil; | |
?> | |
<?php | |
//Contoh koding dengan PBO | |
class Kalkulator { | |
function __construct($a,$b) { | |
$this->a = $a; | |
$this->b = $b; | |
} | |
public function jumlahkan(){ | |
$this->hasil = $a+$b; | |
} | |
public function tampilkanHasil(){ | |
echo "Hasil : ".$this->hasil; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment