Skip to content

Instantly share code, notes, and snippets.

@galihlprakoso
Last active December 8, 2018 16:05
Show Gist options
  • Save galihlprakoso/a68e0c863039709b0fd9023d3dfae361 to your computer and use it in GitHub Desktop.
Save galihlprakoso/a68e0c863039709b0fd9023d3dfae361 to your computer and use it in GitHub Desktop.
galihlprakoso-com-blog-introduction-oop
<?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