// LES CATS EN MAJUSCULES (EXERCICE 1) //
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
$tab = ["cat", "dog", "catapult", "catfish", "dogfish", "catamaran", "This is a cat", "This is a dog"];
echo "<ul>";
for ($i = 0 ; $i < count($tab) ; $i++){
if (strpos($tab[$i],"cat") === false) {
echo "<li>" . $tab[$i] . "</li>";
}
else {
echo "<li>" . strtoupper($tab[$i]) . "</li>";
}
}
echo "</ul>";
?>
</body>
</html>
// USE URL PARAMETERS (EXERCICE 2) //
if (isset($_GET["animal"]) && isset($_GET["sound"])) {
echo("<p>The ".$_GET["animal"]." says ".$_GET["sound"]."</p>");
}
elseif (isset($_GET["animal"])) {
echo("<p>The ".$_GET["animal"]." is silent.</p>");
}
elseif (isset($_GET["sound"])) {
echo("<p>Which animal says ".$_GET["sound"]."?</p>");
}
else {
echo("<p>Nothing to say here...</p>");
}