Problem with "Do While " loop (PHP)


#1


https://www.codecademy.com/fr/courses/web-beginner-fr-FR-gkc3z/0/6?curriculum_id=53710371fed2a8c7e9000001#

Codecademy tells me : "Oups, merci de réessayer.
Avez-vous ajouté un point-virgule après le texte à afficher ?
" (ENGLISH: Have you addded a ";" after the display of the text?"


<!DOCTYPE html>
<html>
    <head>
        <title>Une boucle do-while</title>
    </head>
    <body>
    <?php
        $i = 0;
        do {
            echo $i;
        }  while ($i > 0);
        echo "Voici la valeur $i ";
    ?>
    </body>
</html>


#2

@theoask,
Your link is pointing to Compléter la bouclé
and in the instructions they ask you to
make corrections to the code using { } , ( )

$condition = false;
do 
   echo "<p>La boucle est exécutée une fois alors que la condition est fausse.</p>";
while $condition
echo "<p>Maintenant on est sorti de la boucle.</p>";

Use the =refaire= Button to get the Original exercise text.!!!


#3

I am sorry but the problem comes from Codecademy b ecause I just checked my code with an expert IT programmer at my work and he tells me my code is right:

<?php
    $condition = false;
    do {
        echo "<p>La boucle est exécutée une fois alors que la condition est fausse.</p>";
}
while ($condition);
    
    
    echo "<p>Maintenant on est sorti de la boucle.</p>" ;
?>

I still get the error message that I am missing a ";", but there was none to add since the default code was correct..

regards,


#4

@theoask
Then ask this
IT programmer at my work
what you should do to "reset" the php-Result-record on the 'server'
( cooky file ? )


#5

Can you give me the answer to reset what you said? The IT expert is not here (away).

I flushed the cache file of my browser (Firefox) and reloaded the page, but still don't work...


#6

What Leonhard is trying to say is that you have to push the "Reset code" button, in your case "Refaire" and reinsert the corrections to the code.

clearing your broweser cache in this case will not help.


#7

@theoask,
Although your code is Ok......
the course-checker-code casuses the problem......

From
https://discuss.codecademy.com/t/erreur-dans-lexercice-6-les-boucles-while-en-php/820/7?u=leonhard.wettengmx.n
the quick & dirty soultion

<?php
$condition = false;
do {
echo "La boucle est exécutée; une fois alors que la condition est fausse.";
} while ($condition);
echo "<p>Maintenant on est sorti ;de la boucle.</p>";

?>

#8

bor a force d essayer jai fait un copier coller car le probleme est un bug oui j ai fait un copier collerde cet exemple et ca marche


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.