correction-ulysse #2

Merged
Ulysse JARNOUEN DE VILLARTAY merged 15 commits from jarnouen/web_2025:correction-ulysse into main 2026-04-15 15:34:47 +02:00
5 changed files with 113 additions and 55 deletions
Showing only changes of commit 6dd596e7b3 - Show all commits
+1 -1
View File
@@ -3,7 +3,7 @@
<body>
<?php
echo "<h1>hello world !!!</h1>";
//phpinfo();
phpinfo();
?>
</body>
</html>
+25
View File
@@ -6,6 +6,8 @@ $clients = [
"Arnaud"
];
var_dump($clients);
$produits = [
20 => "Chemise",
3 => "Pantalon",
@@ -23,4 +25,27 @@ print_r($clients);
print_r($produits);
print_r($array);
echo "</pre>";
// Exercice 2.1
$tab = [];
$somme = 0;
for ($i = 0; $i < 10; $i++) {
$somme += $i; // somme des entiers de 0 à i
$tab[$i] = $somme; // la clé i contient cette somme
}
print_r($tab);
// Exercice 2.2
for ($debut = 1; $debut <= 50; $debut += 10) {
echo "<p>";
for ($i = $debut; $i < $debut + 10; $i++) {
if ($i % 2 === 0) {
echo "<strong>$i</strong> ";
} else {
echo "<em>$i</em> ";
}
}
echo "</p>";
}
?>
+19 -2
View File
@@ -28,9 +28,26 @@ include './include/data.inc.php';
</tr>
</thead>
<tbody>
<?php include_once './include/data.inc.php'; ?>
<?php foreach ($data as $person) : ?>
<?php
$poids = (float) $person['Poids'];
$tailleM = (float) $person['Taille'] / 100;
<!-- À compléter -->
$imc = null;
if ($tailleM > 0) {
$imc = $poids / ($tailleM * $tailleM);
}
?>
<tr class="<?= $imc < 18.5 ? 'underweight' : ($imc < 25 ? 'normal' : 'warning') ?>">
<td><?= $person['Nom'] ?></td>
<td><?= $person['Prenom'] ?></td>
<td><?= $person['Email'] ?></td>
<td><?= $person['Taille'] ?></td>
<td><?= $person['Poids'] ?></td>
<td><?= round($imc, 2) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</main>
+20 -4
View File
@@ -1,3 +1,19 @@
<?php
// Generate random values for two six-sided dice.
$die1 = mt_rand(1, 6);
$die2 = mt_rand(1, 6);
$sum = $die1 + $die2;
// Map dice values to matching SVG filenames.
$diceImages = [
1 => 'dice-six-faces-one.svg',
2 => 'dice-six-faces-two.svg',
3 => 'dice-six-faces-three.svg',
4 => 'dice-six-faces-four.svg',
5 => 'dice-six-faces-five.svg',
6 => 'dice-six-faces-six.svg',
];
?>
<!DOCTYPE html>
<html lang="fr">
<head>
@@ -13,12 +29,12 @@
</head>
<body>
<main>
<h5><a href=""> Tirage aléatoire</a></h5>
<h5><a href="./">Tirage aléatoire</a></h5>
<article class="is-center">
<img src='./img/dice-six-faces-five.svg'>
<img src='./img/dice-six-faces-one.svg'>
<img src="./img/<?= $diceImages[$die1] ?>" alt="Dé 1 : <?= $die1 ?>">
<img src="./img/<?= $diceImages[$die2] ?>" alt="Dé 2 : <?= $die2 ?>">
</article>
<h5>Somme = </h5>
<h5>Somme = <?= $sum ?></h5>
</main>
</body>
</html>
+4 -4
View File
@@ -1,7 +1,7 @@
<?php
function createPassword($n,$alphabet){
$length = strlen($alphabet);
$password = "";
return $password;
function createPassword($n,$alphabet) {
$length = strlen($alphabet);
$password = "";
return $password;
}
?>