PHP·98 questions

What is constructor property promotion?

Answer
PHP 8.0+.
public function __construct(public string $name).
Declaring property in constructor.
Less boilerplate code.
Works with access modifiers.
Was this answer helpful?

More questions in this topic

Related questions from other topics