Quiz · Classes and objects · lesson 11 of 11
Quiz — writing to readonly
What happens when you run this program?
<?php
class Ticket
{
public function __construct(public readonly int $id) {}
}
$t = new Ticket(7);
echo $t->id, "\n";
$t->id = 8;
echo $t->id, "\n";