Missing semi-colon on guide code?


#1



https://www.codecademy.com/courses/web-beginner-en-8a35h/0/4?curriculum_id=5124ef4c78d510dd89003eb8#


Hello, so, my code is working well enough, but I am a little confused. I am fairly certain the echo command needs to end in a semi colon. However, in the guide/lesson, there is not a semi-colon at the end of the echo command that references the array statement (specifically "echo $myArray[0]").

In the "hint" area, there IS a semi-colon present. And when I put a semi-colon in my code it was okay. However... it also seemed to work well enough when I didn't add the semi-colon. I am a fan of semi-colons as that seems more organised.

Is there a special case that does not require the semi-colon because it is involving arrays?

Thank you for your time and efforts.


<?php
$myArray = array("do", "re", "mi");

echo $myArray[0];       //<----- ?
// outputs "do"

?>


#2

In the normal sense, a semi-colon is mandatory on all PHP statements, with one exception. The last one in a function, or the last one in the global code. The above line would qualify under the latter condition.


#3

Ah! Thank you! That helps a large amount in my understanding why it didn't cause an error!