correction-ulysse (#2)

# Correction pour les TP1 TP2 et TP3

Je n'ai pas testé la connexion à la DB pour le moment car je ne peux pas me co sur https://dwarves.iut-fbleau.fr/phpmyadmin

Co-authored-by: JARNOUEN DE VILLARTAY Ulysse (SAFRAN AIRCRAFT ENGINES) <ulysse.jarnouen-de-villartay@safrangroup.com>
Reviewed-on: monnerat/web_2025#2
This commit is contained in:
2026-04-15 15:34:46 +02:00
parent 045ec81ae2
commit a4580652f8
22 changed files with 692 additions and 215 deletions
+35 -10
View File
@@ -1,17 +1,19 @@
<?php
$clients = [
"Luc",
7 => "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 "</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>";
}
?>