Can someone explain the error to the php code below? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can someone explain the error to the php code below?

<?php $i = 1 do { echo "The number is" . $i . "<br/>"; $i++; } while($i < 10); ?>

12th Jul 2018, 4:52 PM
Marios
3 Answers
+ 3
Hello, Marios ! The problem is in the smallest. You just forgot to put the ";" on the variable $i which equals 1. SoloLearn:"PHP statements end with semicolons (;)" <?php $i = 1; do { echo "The number is" . $i . "<br/>"; $i++; } while($i < 10); ?> https://www.sololearn.com/learn/PHP/1793/
12th Jul 2018, 4:55 PM
Alexander Sokolov
Alexander Sokolov - avatar
0
it comes up with the error Parse error: syntax error, unexpected 'do' (T_DO) in ..\Playground\ PHP Parse error: syntax error, unexpected 'do' (T_DO) in ..\Playground\
12th Jul 2018, 4:53 PM
Marios
0
Thank you! I'm new with php so I didn't see that detail!
12th Jul 2018, 4:57 PM
Marios