Question from the PHP8 test

Write to a nullsafe property in PHP

Hard

What will be displayed?

<?php

class User
{
    public string $name = 'Doe';
}

class Article
{
    public ?User $user;
   
}

$article = new Article;
$article->user = new User;

$article?->user?->name = 'Dupont';

echo $article->user->name;
Author: W3D TeamStatus: PublishedQuestion passed 807 times
Edit
2
Community EvaluationsNo one has reviewed this question yet, be the first!