<?php
class User
{
public function __construct(protected string $firstName, protected string $lastName){}
public function __toString(): string {
return sprintf("%s %s", $this->firstName, $this->lastName);
}
}
$user = new User("Matthew", "Setter");
echo $user;
Join the discussion
comments powered by Disqus