Rofihimam

Untitled

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