How to code properties

How to code a property

The syntax (access modifiers)

[ public | protected | private ] $propertyName [ = initialValue ];

A private property

private $firstName;

A public property with a default value

public $comment = '';

A protected property

protected $counter;

Five properties on the same line

private $category, $id, $name, $description, $price;

Description

Back