<?php Class User { protected $name; protected $age; public function __construct($name,$age){ $this->name = $name; $this->age = $age; } } class Customer extends User { private $balance; public function __construct($name,$age,$balance) { $this->balance = $balance; parent::__construct($name,$age); } public function getBalance() { return $this->balance; } public function pay($amount) { return $this->name . ' paid $'. $amount; } } $customer1 = new Customer('John',33, 500); echo $customer1->getBalance();
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter