Why can print_r
see the private property $version even when its scope is set to private?
class myClass {
private $version;
public function set_version($value){
$this->version = $value;
}
}
$class = new myClass();
$class->set_version("1.2");
echo "<pre>";
print_r($class);
private
object properties are primarily in the context of class inheritance, and internal scope, only.private
means "secure". It's only an indicator for how this property should be used, it doesn't provide any actual "security" or in fact "real privacy".