Stratician

PHP Classes

Jan 27th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.43 KB | None | 0 0
  1. <?php
  2.  
  3.         class Hotel
  4.         {
  5.             public $name;
  6.             public $rooms = 200;
  7.             public $booked = 80;
  8.             public $hasPool; // Boolean Value
  9.  
  10.             public function roomsAvailable()
  11.             {
  12.                 $available = $this->rooms - $this->booked;
  13.                 return "There are " . $available . " rooms available";
  14.             }
  15.  
  16.         }
  17.  
  18.         $ReubenInn = new Hotel;
  19.  
  20.         $ReubenInn->name = "ReubenInn";
  21.         $ReubenInn->hasPool = true;
  22.  
  23.         echo $ReubenInn->roomsAvailable();
  24.  
  25.     ?>
Advertisement
Add Comment
Please, Sign In to add comment