Question from the PHP8 test

Display the name of the user associated with an article in PHP

Medium

What will be displayed?

<?php

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

class Article
{
    public ?User $user = null;
   
}

$article = new Article;

echo $article?->user?->name;
Author: W3D TeamStatus: PublishedQuestion passed 704 times
Edit
1
Community Evaluations
developer avatar
Mehdi
22/02/2024
Ici pourquoi ce n'est Doe ? Je viens de voir par rapport a Article je pense avoir compris mon erreur.