PHP theorytheory 0/50 · 0%
OOP · easy

11. Constructors & Properties

Initializing object state.

Constructor property promotion (PHP 8) lets you declare and assign typed properties directly in the constructor signature, reducing boilerplate. Default property values can be set at declaration time.

Static properties belong to the class itself rather than any instance and are accessed with ClassName::$property.

Check your understanding

  1. 1. What does constructor property promotion do?

  2. 2. How do you access a static property?