Question from the PHP8 test

What will this code display?

Easy

What will this code display?

<?php

class MyAwesomeClass
{
	public function __construct(public string|null $name = null){}
	
	public function setName(string $name): self
	{
		$this->name = $name;
		
		return $this;
	}
}

echo (new MyAwesomeClass())->setName('My awesome name')->name;
Author: JérômeStatus: PublishedQuestion passed 37 times
Edit
-1
Community Evaluations
developer avatar
Incorrect answer
Jérôme
16/02/2024
Seule la seconde réponse est bonne. J'ai oublié de valider les bonnes réponses avant de soumettre...