A typo has slipped into the fourth article: 'titr' => … instead of 'titre' => …. Look at the preview: the soup contest came out without a title. With arrays, PHP gets by with a warning (“Undefined array key”) and prints the page anyway, title or no title. Madame Lou wants an article template that nobody can fill in the wrong way: a class.
Your mission
- Declare an
Articleclass whose constructor receives, in this order:string $titre(title),string $auteur(author),string $rubrique(section),string $texte(text) andbool $une(front page), which isfalseby default. Turn them into public properties with constructor promotion: writepublic string $titreright in the constructor. - Replace the four arrays with objects:
new Article(titre: '…', auteur: '…', …). - Change
afficherArticle()so that it receives anArticle:$article->titrereplaces$article['titre'].
The front page must not change.
Reminder
A class is a blueprint; an object is a thing built from that blueprint with new. The constructor __construct() runs when the object is created. Its parameters preceded by public become properties, which you read with the arrow ->. A typo in a named argument is an error, and PHP reports it right away.