<?php class User { public string $name { set { if (strlen($value) === 0) { throw new ValueError("Name must be non-empty"); } $field = ucfirst($value); } } public function __construct(string $name) { $this->name = $name; } } $u = new User('roman'); var_dump($u->name);
You have javascript disabled. You will not be able to edit any code.