PHP Property Visibility Quest

Quick question on this statement from php.net:

“Members declared protected can be accessed only within the class itself and by inherited and parent classes”

So a parent class can access the protected properties of its children classes? Even if it doesn’t declare the property itself?

If so a quick use case of this?

Thanks

Yes that’s correct, any class that gets extended by the parent automatically inherits properties both ways there for protected properties are accessible.

class A {
    protected $text = 'Hello World!';
}

class B extends class A {
    public function __construct() {
        echo parent::$text;
    }
}

$myClass = new B;