Bonjour,
J'ai un problême avec mon else if mais je ne sais pas pk
Parse error: syntax error, unexpected 'elseif' (T_ELSEIF) in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\jeu_capitales\data.php on line 160
<?php
$countries = [
"Albanie",
"Allemagne",
"Andorre",
"Autriche",
"Belgique",
"Biélorussie",
"Bulgarie",
"Chypre",
"Croatie",
"Danemark",
"Écosse",
"Espagne",
"Estonie",
"Finlande",
"France",
"Grande-Bretagne",
"Grèce",
"Hongrie",
"Irlande",
"Irlande du Nord",
"Islande",
"Ile de Man",
"Italie",
"Jersey",
"Lettonie",
"Liechtenstein",
"Lituanie",
"Luxembourg",
"Malte",
"Moldavie",
"Monaco",
"Monténégro",
"Norvège",
"Pays Bas",
"Pologne",
"Portugal",
"République tchèque",
"Roumanie",
"Saint-Marin",
"Serbie",
"Slovaquie",
"Slovénie",
"Suède",
"Suisse",
"Vatican",
];
$capitals = [
"Tirana",
"Berlin",
"Andorre La Vieille",
"Vienne",
"Bruxelles",
"Minsk",
"Sofia",
"Nicosie",
"Zagreb",
"Copenhague",
"Édimbourg",
"Madrid",
"Tallinn",
"Helsinki",
"Paris",
"Londres",
"Athènes",
"Budapest",
"Dublin",
"Belfast",
"Reykjavik",
"Douglas",
"Rome",
"Saint-Hélier",
"Riga",
"Vaduz",
"Vilnius",
"Luxembourg",
"La Valette",
"Chisinau",
"Monaco",
"Podgorica",
"Oslo",
"Amsterdam",
"Varsovie",
"Lisbonne",
"Prague",
"Bucarest",
"Saint-Marin",
"Belgrade",
"Bratislava",
"Ljubljana",
"Stockholm",
"Berne",
"Cité du Vatican",
];
echo "<h1>Etape 3</h1>";
$taille = count($countries);
$nb1 = rand(0, $taille);
$nb2 = rand(0, $taille);
$nb3 = rand(0, $taille);
$nb4 = rand(0,3);
if ($nb4 = 1)
{
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jeu des capitales</title>
</head>
<body>
<fieldset>
<legend>Jeu des capitales</legend>
<p>
<?php
echo "Quelle est la capital de $countries[$nb1]";
?>
</p>
<form action="#" method="post">
<p>
<?php
echo $capitals[$nb1]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$n2]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$nb3]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<button type="submit" name="confirmer" value="envoyer">Confirmer</button>
</form>
</fieldset>
<?php
elseif ($nb4 = 2) {
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jeu des capitales</title>
</head>
<body>
<fieldset>
<legend>Jeu des capitales</legend>
<p>
<?php
echo "Quelle est la capital de $countries[$nb1]";
?>
</p>
<form action="#" method="post">
<p>
<?php
echo $capitals[$nb2]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$nb3]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$nb1]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<button type="submit" name="confirmer" value="envoyer">Confirmer</button>
</form>
</fieldset>
}
<?php
elseif ($nb4 = 3)
{
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Jeu des capitales</title>
</head>
<body>
<fieldset>
<legend>Jeu des capitales</legend>
<p>
<?php
echo "Quelle est la capital de $countries[$nb1]";
?>
</p>
<form action="#" method="post">
<p>
<?php
echo $capitals[$nb3]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$nb1]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<p>
<p>
<?php
echo $capitals[$nb2]
?>
<input type="radio" name="capitale" value="">
<span class="erreur"></span>
</p>
<button type="submit" name="confirmer" value="envoyer">Confirmer</button>
</form>
</fieldset>
}
<fieldset>
<legend>Résultat</legend>
<?php
if ($capitals = $nb3)
{
echo "Bravo, tu as juste";
}
?>
</fieldset>
</body>
</html>
<?php
}
?>
EDIT : Correction des balises de code => Ajout du LANGAGE pour avoir la coloration syntaxique et la numérotation des lignes !
Afficher la suite