public $number; public $RAM; public $CPU; public $modGSM = "TRUE"; public $OS; public function call($abonent) { if ($this->modGSM) { echo "Calling to " . $abonent . " from" . $this->number . "<br>"; } echo "I am not able to call, please send me email."; } } class Phone extends mobile { } $nokia = new Phone(); $nokia->number = "+380954801117"; $nokia->call("Mike"); class Tablet extends mobile { public $modGSM = "FALSE"; } $lg = new Tablet(); if ($nokia instanceof mobile) { echo "nokia is Phone"; } if ($nokia instanceof Tablet) { echo "Are you sure?"; } $lg->call(12345);
<?php /** * Created by PhpStorm. * User: salon02 * Date: 09.08.15 * Time: 15:00 */ class Phone { public function getNumberByName($name) { } protected function dialNumber() { } public function call($name) { $number = $this->getNumberByName($name); $this->dialNumber($number); } } $phone1 = new Phone(); $phone1->call('Саша5');