class Automobile
{
public $fuel;
protected $engine="1500CC";
public function eng(){
return($this->engine);
}
}
$automobile = new Automobile;
echo $automobile->fuel = 'Petrol';
echo $automobile->engine;
echo $automobile->eng();
Here echo $automobile->engine;
cause me fatal error. That is correct.
NoI i created a public function eng()
to use the protected variable engine outside the class it works for me.
My question is by using the public function I can access the protected variable so then I can access it anywhere so basically I converted protected variable to public variable this is a statement in bold is right??