So , I'm new to PHP and I know this is an easy question for a lot of you , but I'm not sure about one thing.
If I have this , the new object $a
and $d
can't echo the function foo()
, because it's protected , so it means that only sub classes can use it , OBJECT can't?
It's a bit confusing for me.
Sorry if it's a stupid question , but I don't have a php friend to ask this.
<?php
class A {
protected function foo(){
echo "AAA";
}
}
class D extends A { }
$a = new A();
$d = new D();
$a->foo();
$d->foo();
?>