Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ulzhang's avatar

Auto add a semicolon to end of line

I'm used to Prettier auto formatting a semi-colon at the end of my javascript code. But it doesn't work as well on php code. Does anyone have a solution for this? I'm a VS Code user.

I loathe this error statement. Unexpected '}'. Expected ';'.intelephense(P1001)

0 likes
5 replies
Tray2's avatar

Learn to put it there yourself, otherwise it becomes a bad habit and you will be chasing the missing ones.

2 likes
Snapey's avatar

I have a solution, use an IDE that understands PHP. It will immediately tell you that you have an unterminated statement.

2 likes
Tray2's avatar

@ulzhang No it won't. Just get into the habit of adding it yourself, it will help you in the long run.

2 likes
Snapey's avatar

@ulzhang In Javascript the semi colon is a matter of preference. In PHP it is a mandatory part of the language. Its the same as remembering to type $ before your variables. You will learn it in about 2 days of coding.

The point about the IDE is that if for some reason you forget, your ide will suggest there is something wrong.

1 like

Please or to participate in this conversation.