سؤال

Is it possible to do something like this:

class foo {
    private $private = 'A';
}

class bar extends foo {
    echo $this->private;
}

bar returns null...

I'd really like it if the variable $private wasn't accessible by the child classes, but I'm unsure that it's even possible based simply on the paradigm of classed based development.

Private properties DO NOT provide the functionality I'm looking for.

I understand that this isn't accurate PHP code, but it's just an example ;)

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top