This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Arrays Forum

View Course » View Exercise

55 points
Bf6372d68fbd76489a1310bc79b494fb?s=140&d=retro
Submitted by
naturalstate
almost 3 years ago

Why doesn't the example have a semicolon?

Why doesn't the example have a semicolon after echo $myarray [0] ?

I added one : echo $myarray [0]; and it works just like it does without it. I thought all statements had to have a semicolon?


0 votes

permalink

this is what i found.

seems not to be always neccessary (as long as you DO start a new line, like in JS)?

565 points
979959283057c57a3f6d3e87c633b2b4?s=140&d=retro
Submitted by
jimhatesaccounts
almost 3 years ago


0 votes

permalink

Hi,

You are right it isn't always necessary to add the semicolon but your code between <?php and ?> must not exceed one line. If the code exceeds one line you will receive a parse error. But the best it's to put always the semicolons.

Greetings

180 points
Dd8d4ebfb489fd55013f164fd59a7f93?s=140&d=retro
Submitted by
Florian Martinez
almost 3 years ago