From 6dd596e7b35e2eafc090eea25c5498e98a1fc6ae Mon Sep 17 00:00:00 2001 From: "JARNOUEN DE VILLARTAY Ulysse (SAFRAN AIRCRAFT ENGINES)" Date: Thu, 2 Apr 2026 13:48:28 +0200 Subject: [PATCH] add correction --- R3.01/tp/tp1/ex1/hello-world.php | 12 ++-- R3.01/tp/tp1/ex2/index.php | 45 +++++++++++---- R3.01/tp/tp1/ex3/index.php | 79 ++++++++++++++++----------- R3.01/tp/tp1/ex4/index.php | 24 ++++++-- R3.01/tp/tp1/ex6/include/fonction.php | 8 +-- 5 files changed, 113 insertions(+), 55 deletions(-) diff --git a/R3.01/tp/tp1/ex1/hello-world.php b/R3.01/tp/tp1/ex1/hello-world.php index 11a784f..183c053 100644 --- a/R3.01/tp/tp1/ex1/hello-world.php +++ b/R3.01/tp/tp1/ex1/hello-world.php @@ -1,9 +1,9 @@ - - hello world !!!"; - //phpinfo(); - ?> - + + hello world !!!"; + phpinfo(); + ?> + diff --git a/R3.01/tp/tp1/ex2/index.php b/R3.01/tp/tp1/ex2/index.php index 90e8baa..83fc42a 100644 --- a/R3.01/tp/tp1/ex2/index.php +++ b/R3.01/tp/tp1/ex2/index.php @@ -1,17 +1,19 @@ "Paul", - 2 =>"Martin", - "Arnaud" +$clients = [ + "Luc", + 7 => "Paul", + 2 =>"Martin", + "Arnaud" ]; +var_dump($clients); + $produits = [ - 20 => "Chemise", - 3 => "Pantalon", - 10 => "Jupe", - "Veste", - "Blouson" + 20 => "Chemise", + 3 => "Pantalon", + 10 => "Jupe", + "Veste", + "Blouson" ]; $array = ["a","b","c"]; $array[] = "d"; @@ -23,4 +25,27 @@ print_r($clients); print_r($produits); print_r($array); echo ""; + +// 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 "

"; + for ($i = $debut; $i < $debut + 10; $i++) { + if ($i % 2 === 0) { + echo "$i "; + } else { + echo "$i "; + } + } + echo "

"; +} ?> diff --git a/R3.01/tp/tp1/ex3/index.php b/R3.01/tp/tp1/ex3/index.php index f031367..55f0ee4 100644 --- a/R3.01/tp/tp1/ex3/index.php +++ b/R3.01/tp/tp1/ex3/index.php @@ -3,36 +3,53 @@ include './include/data.inc.php'; ?> - - - - tp1 - ex3 - - - - -
-

Exercice 3 : IMC

- - - - - - - - - - - - + + + + tp1 - ex3 + + + + +
+

Exercice 3 : IMC

+
NomPrénomEmailTaillePoidsIMC
+ + + + + + + + + + + + + + - - -
NomPrénomEmailTaillePoidsIMC
-
- + $imc = null; + if ($tailleM > 0) { + $imc = $poids / ($tailleM * $tailleM); + } + ?> + + + + + + + + + + + + + diff --git a/R3.01/tp/tp1/ex4/index.php b/R3.01/tp/tp1/ex4/index.php index 1db7b37..18c1bbf 100644 --- a/R3.01/tp/tp1/ex4/index.php +++ b/R3.01/tp/tp1/ex4/index.php @@ -1,3 +1,19 @@ + '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', +]; +?> @@ -13,12 +29,12 @@
-
Tirage aléatoire
+
Tirage aléatoire
- - + Dé 1 : <?= $die1 ?> + Dé 2 : <?= $die2 ?>
-
Somme =
+
Somme =
diff --git a/R3.01/tp/tp1/ex6/include/fonction.php b/R3.01/tp/tp1/ex6/include/fonction.php index 10aaf04..2c0856b 100644 --- a/R3.01/tp/tp1/ex6/include/fonction.php +++ b/R3.01/tp/tp1/ex6/include/fonction.php @@ -1,7 +1,7 @@