I do not want to make the properties of class example accessible only to it’s children, but I want the children to be able to change them apart from the initial __construct. This is how I have things set up at the moment. Can I be doing this a better way?
class example{
private $x
protected function __construct($x){
setX($x);
}
private function setX($x){
$this->x = $x;
}
protected function getX{
return $this->x;
}
}
Do I understand correctly that you only want $x to be readable (but not editable) by it’s children?
Then yes your class definition looks alright (albeit the syntax errors).
Children cannot access private members, only protected (and public, durhur).