Session BRE05 Help

Exercice 1 : correction

User.php

<?php class User { public function __construct(private int $id, private string $username, private string $password) { } public function getId() : int { return $this->id; } public function setId(int $id) : void { $this->id = $id; } public function getUsername() : string { return $this->username; } public function setUsername(string $username) : void { $this->username = $username; } public function getPassword() : string { return $this->password; } public function setPassword(string $password) : void { $this->password = $password; } }

index.php

<?php require "User.php"; $admin = new User(1, "admin", "admin"); $user = new User(2, "user, "user"); echo "ID utilisateur : ${$admin->getId()} Username : ${$admin->getUsername()} MDP : ${$admin->getPassword()} <br>"; echo "ID utilisateur : ${$user->getId()} Username : ${$user->getUsername()} MDP : ${$user->getPassword()} <br>";
26 February 2026