<?php
class Access{
public $name = "No name";
protected $age;
private $code;
public function __construct($name , $age , $code){
$this->name = $name;
$this->age = $age;
$this->code = $code;
}
public function getDetails(){
echo "Name = $this->name , Age = $this->age , Code = $this->code";
}
}
class Enhance extends Access{
public function showDetails(){
echo "Name = $this->name , Age = $this->age , Code = $this->code"; // cannot access $code here
}
}
$newObj = new Access("Sudhir" , 24 , 334455);
echo $newObj->name;
// echo $newObj->age;
// echo $newObj->code;
$secondObj = new Enhance("Samay" , 21 , 445566);
$secondObj->showDetails();
To embed this program on your website, copy the following code and paste it into your website's HTML: