Properties¶
Class properties are variables, local to an object or a class.
They might have visibility, chosen among : public (default), protected and private.
They might have a default value. By default it is null.
They might have a type, since PHP 7.4
They might be readonly, for properties which are only set once, and cannot be modified.
They might be static, and not related to an object, but to a class.
Property should be uniquely defined in a class. They may be redefined in children or parent when the visibility allows it.
<?php
class X {
private $property = 1;
}
?>
See also PHP OOP properties
Related : Visibility, static, Readonly, Attributes, Default Value, Magic Property, Dynamic Properties, Property Hook, Asymetric Visibility, Type System