Properties

Class properties are variables, local to an object or a class.

Class properties might have visibility, chosen among: public, protected and private. public is the default.

Class properties might have an asymmetric visiblity for writing, chosen among: public(set), protected(set) and private(set). By default, it is the same as the read visibility.

Class properties might have a default value. By default it is null.

Class properties might have a type, since PHP 7.4

Class properties might be readonly, for properties which are only set once, and cannot be modified.

Class properties might be static, and not related to an object, but to a class.

A property must be uniquely defined in a class. Class properties may be redefined in children or parent when the visibility allows it.

Properties are also called members.

<?php

    class X {
        private $property = 1;
    }

?>

Documentation

See also Class properties.

Related : Visibility, static, Readonly, Attribute, Default Value, Magic Property, Dynamic Properties, Property Hook, Asymmetric Visibility, Type System, Asymmetric Visibility, Data Container, Static Property, stdclass, Typed Property, Method, Readable, Virtual Property, Writable, get_object_vars(), Promoted Properties, Property Type Declaration, Var, Writeable, Non-static, State