I am a beginner in Object Oriented Programming. I am confused with a variable being declared as PRIVATE.
<?php class dog { private $Name; } class poodle extends dog { public function test($test){ $this->Name = $test; } } $poppy = new poodle; $poppy->test("test"); echo $poppy->Name; ?> As I've read, "Private variables can only be accessed by the exact class that owns them - child classes cannot access private parent functions variables"
My question is if $Name is a private property, why was the output of the script returned "test" ? Shouldn't it have output an error message since another class is trying to access a private property?