Rofihimam

Untitled

Feb 5th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2.     include 'KelompokMakan.php';
  3.     class Manusia extends KelompokMakan
  4.     {
  5.         public $jenis_kelamin;
  6.         public $nama;
  7.         public $tanggal_lahir;
  8.  
  9.         public function bersuara()
  10.         {
  11.             return $this->nama;
  12.         }
  13.  
  14.         public function usia()
  15.         {
  16.             $date = date_create_from_format("d/m/Y", $this->tanggal_lahir);
  17.             $tahunLahir = $date->format('Y');
  18.             $tahunSekarang = date('Y');
  19.             $usia = $tahunSekarang - $tahunLahir;
  20.             return $usia;
  21.         }
  22.     }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment